Skip to content

Commit

Permalink
Fix ParseException when no response is returned for past name lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerkok committed Feb 5, 2015
1 parent cd8f312 commit e65f75e
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ Map<String, Result> uuidLookupInPast(List<String> names, Date timestamp) throws
for (String name : names) {
String urlString = PAST_PROFILE_URL + '/' + name + "?at=" + epochSeconds;
URL url = new URL(urlString);
JSONObject object = (JSONObject) jsonParser
.parse(new InputStreamReader(url.openStream()));
String newName = (String) object.get("name");
UUID uuid = parseMojangUniqueId((String) object.get("id"));
uuidMap.put(name, new Result(newName, uuid));
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if (connection.getResponseCode() == 200) {
JSONObject object = (JSONObject) jsonParser
.parse(new InputStreamReader(connection.getInputStream()));
String newName = (String) object.get("name");
UUID uuid = parseMojangUniqueId((String) object.get("id"));
uuidMap.put(name, new Result(newName, uuid));
}

Thread.sleep(100L);
}
Expand Down Expand Up @@ -256,7 +259,6 @@ public ResultConsumer(boolean resultsOnServerThread) {
*/
private static final int MAX_SIGN_LINE_LENGTH = 15;


private static final Pattern validUserPattern = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
private static final UUID ZERO_UUID = new UUID(0, 0);

Expand Down Expand Up @@ -339,6 +341,7 @@ private static void writeBody(HttpURLConnection connection, String body)
stream.flush();
stream.close();
}

private final Logger logger;

private final MojangWeb mojangWeb = new MojangWeb();
Expand Down

0 comments on commit e65f75e

Please sign in to comment.