Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ def main() -> None:
"NP_LOAD_OF_KNOWN_NULL_VALUE",
"NP_BOOLEAN_RETURN_NULL",
"REFLC_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_CLASS",
"REC_CATCH_EXCEPTION",
"UI_INHERITANCE_UNSAFE_GETRESOURCE",
"URF_UNREAD_FIELD",
"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void run() {
LOCK.wait(100);
}
}
} catch (Exception err) {
} catch (InterruptedException err) {
err.printStackTrace();
}
}
Expand Down
20 changes: 10 additions & 10 deletions CodenameOne/src/com/codename1/io/JSONParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,19 +431,19 @@ public static void parse(Reader i, JSONParseCallback callback) throws IOExceptio
}
}
}
} catch (Exception err) {
Log.e(err);
Log.p("Exception during JSON parsing at row: " + row + " column: " + column + " buffer: " + currentToken);
/*System.out.println();
int current = i.read();
while(current >= 0) {
System.out.print((char)current);
current = i.read();
}*/
i.close();
} catch (IOException err) {
handleParsingException(i, err, row, column, currentToken);
} catch (RuntimeException err) {
handleParsingException(i, err, row, column, currentToken);
}
}

private static void handleParsingException(Reader i, Exception err, int row, int column, StringBuilder currentToken) throws IOException {
Log.e(err);
Log.p("Exception during JSON parsing at row: " + row + " column: " + column + " buffer: " + currentToken);
i.close();
}

/**
* Static method to convert the given {@link java.util.Map} to a valid JSON
* representation. The values allowed types are: {@link java.lang.Number}, {@link java.lang.String}, {@link java.lang.Boolean},
Expand Down
14 changes: 10 additions & 4 deletions CodenameOne/src/com/codename1/io/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,19 @@ protected Writer createWriter() throws IOException {
} else {
return Util.getWriter(FileSystemStorage.getInstance().openOutputStream(getFileURL()));
}
} catch (Exception err) {
setFileWriteEnabled(false);
// currently return a "dummy" writer so we won't fail on device
return Util.getWriter(new ByteArrayOutputStream());
} catch (IOException err) {
return fallbackWriterAfterError();
} catch (RuntimeException err) {
return fallbackWriterAfterError();
}
}

private Writer fallbackWriterAfterError() {
setFileWriteEnabled(false);
// currently return a "dummy" writer so we won't fail on device
return Util.getWriter(new ByteArrayOutputStream());
}

private Writer getWriter() throws IOException {
if (output == null) {
output = createWriter();
Expand Down
8 changes: 7 additions & 1 deletion CodenameOne/src/com/codename1/io/Socket.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ public void run() {
sc.connectionError(Util.getImplementation().getSocketErrorCode(connection), Util.getImplementation().getSocketErrorMessage(connection));
}
}
} catch (Exception err) {
} catch (InstantiationException err) {
// instansiating the class has caused a problem
Log.e(err);
} catch (IllegalAccessException err) {
// instansiating the class has caused a problem
Log.e(err);
} catch (RuntimeException err) {
// instansiating the class has caused a problem
Log.e(err);
}
Expand Down
66 changes: 46 additions & 20 deletions CodenameOne/src/com/codename1/io/rest/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,15 @@ public Response<PropertyBusinessObject> getAsProperties(Class type) {
CN.addToQueueAndWait(request);
Map response = ((Connection) request).json;
try {
PropertyBusinessObject pb = (PropertyBusinessObject) type.newInstance();
pb.getPropertyIndex().populateFromMap(response);
PropertyBusinessObject pb = createBusinessObject(type, response);
return new Response(request.getResponseCode(), pb, request.getResponseErrorMessage());
} catch (Exception err) {
} catch (InstantiationException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (IllegalAccessException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (RuntimeException err) {
Log.e(err);
throw new RuntimeException(err.toString());
}
Expand Down Expand Up @@ -718,14 +723,15 @@ public Response<List<PropertyBusinessObject>> getAsPropertyList(Class type, Stri
if (lst == null) {
return null;
}
List<PropertyBusinessObject> result = new ArrayList<PropertyBusinessObject>();
for (Map m : lst) {
PropertyBusinessObject pb = (PropertyBusinessObject) type.newInstance();
pb.getPropertyIndex().populateFromMap(m);
result.add(pb);
}
List<PropertyBusinessObject> result = buildBusinessObjectList(type, lst);
return new Response(request.getResponseCode(), result, request.getResponseErrorMessage());
} catch (Exception err) {
} catch (InstantiationException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (IllegalAccessException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (RuntimeException err) {
Log.e(err);
throw new RuntimeException(err.toString());
}
Expand Down Expand Up @@ -815,6 +821,20 @@ private Connection createRequest(boolean parseJson) {
return req;
}

private static PropertyBusinessObject createBusinessObject(Class type, Map response) throws InstantiationException, IllegalAccessException {
PropertyBusinessObject pb = (PropertyBusinessObject) type.newInstance();
pb.getPropertyIndex().populateFromMap(response);
return pb;
}

private static List<PropertyBusinessObject> buildBusinessObjectList(Class type, List<Map> lst) throws InstantiationException, IllegalAccessException {
List<PropertyBusinessObject> result = new ArrayList<PropertyBusinessObject>();
for (Map m : lst) {
result.add(createBusinessObject(type, m));
}
return result;
}

private static class FetchAsPropertyListActionListener implements ActionListener<NetworkEvent> {
private final Connection request;
private final String root;
Expand Down Expand Up @@ -843,15 +863,16 @@ public void actionPerformed(NetworkEvent evt) {
return;
}
try {
List<PropertyBusinessObject> result = new ArrayList<PropertyBusinessObject>();
for (Map m : lst) {
PropertyBusinessObject pb = (PropertyBusinessObject) type.newInstance();
pb.getPropertyIndex().populateFromMap(m);
result.add(pb);
}
List<PropertyBusinessObject> result = buildBusinessObjectList(type, lst);
res = new Response(evt.getResponseCode(), result, evt.getMessage());
callback.completed(res);
} catch (Exception err) {
} catch (InstantiationException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (IllegalAccessException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (RuntimeException err) {
Log.e(err);
throw new RuntimeException(err.toString());
}
Expand Down Expand Up @@ -932,11 +953,16 @@ public void actionPerformed(NetworkEvent evt) {
Response res = null;
Map response = (Map) evt.getMetaData();
try {
PropertyBusinessObject pb = (PropertyBusinessObject) type.newInstance();
pb.getPropertyIndex().populateFromMap(response);
PropertyBusinessObject pb = createBusinessObject(type, response);
res = new Response(evt.getResponseCode(), pb, evt.getMessage());
callback.completed(res);
} catch (Exception err) {
} catch (InstantiationException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (IllegalAccessException err) {
Log.e(err);
throw new RuntimeException(err.toString());
} catch (RuntimeException err) {
Log.e(err);
throw new RuntimeException(err.toString());
}
Expand Down
8 changes: 7 additions & 1 deletion CodenameOne/src/com/codename1/properties/InstantUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,13 @@ private void createEntryForProperty(PropertyBase b, Container cnt,
cnt.add(b.getLabel()).
add(cmp);
allBindings.add(uib.bind(b, cmp));
} catch (Exception err) {
} catch (InstantiationException err) {
Log.e(err);
throw new RuntimeException("Custom property instant UI failed for " + b.getName() + " " + err);
} catch (IllegalAccessException err) {
Log.e(err);
throw new RuntimeException("Custom property instant UI failed for " + b.getName() + " " + err);
} catch (RuntimeException err) {
Log.e(err);
throw new RuntimeException("Custom property instant UI failed for " + b.getName() + " " + err);
}
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/ui/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ void edtLoopImpl() {
paintTransitionAnimation();
return;
}
} catch (Exception ignor) {
} catch (RuntimeException ignor) {
Log.e(ignor);
}
long currentTime = System.currentTimeMillis();
Expand Down
4 changes: 3 additions & 1 deletion CodenameOne/src/com/codename1/ui/html/HTMLComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,9 @@ private void handleImageMapArea(HTMLElement areaTag) {
// Note: The 'circle' SHAPE in AREA tag is implemented as a rectangle to avoid complication of circle pixel collision
error = false;
}
} catch (Exception e) { // Can be number format exception or index out of bounds
} catch (NumberFormatException e) { // Can be number format exception or index out of bounds
// do nothing - error will stay true
} catch (IndexOutOfBoundsException e) {
// do nothing - error will stay true
}
if (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,12 @@ public static CC parseComponentConstraint(String s) {

throw new IllegalArgumentException("Unknown keyword.");

} catch (Exception ex) {
} catch (RuntimeException ex) {
Log.e(ex);
throw new IllegalArgumentException("Error parsing Constraint: '" + part + "'");
}
}

// cc = (CC) serializeTest(cc);
return cc;
}

Expand Down
Loading