Fix possible sync problems
This commit is contained in:
parent
d77fe329b8
commit
896a2be120
1 changed files with 9 additions and 3 deletions
|
@ -32,12 +32,14 @@ public class RouteMapper{
|
|||
}
|
||||
|
||||
public boolean exec(Context context, String path, User user, HttpReader reader, HttpWriter writer) throws Exception{
|
||||
Response result = null;
|
||||
Matcher matcher = null;
|
||||
synchronized(responses){
|
||||
for(int i = 0; i < responses.length; i++){
|
||||
Response response = responses[i];
|
||||
Route route = routes[i];
|
||||
Pattern pattern = patterns[i];
|
||||
Matcher matcher = pattern.matcher(path);
|
||||
matcher = pattern.matcher(path);
|
||||
if(matcher.matches()){
|
||||
if(user == null && route.needLogin()){
|
||||
writer.response(401, "Access-Control-Allow-Origin: *");
|
||||
|
@ -48,12 +50,16 @@ public class RouteMapper{
|
|||
reader = new WebSocketReader(reader);
|
||||
writer = new WebSocketWriter(writer);
|
||||
}
|
||||
response.exec(matcher, context, reader, writer);
|
||||
order(i);
|
||||
result = response;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(result != null){
|
||||
result.exec(matcher, context, reader, writer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue