diff --git a/.github/scripts/generate-quality-report.py b/.github/scripts/generate-quality-report.py index 9084a2a20f..f6b4cb24a2 100755 --- a/.github/scripts/generate-quality-report.py +++ b/.github/scripts/generate-quality-report.py @@ -778,6 +778,7 @@ def main() -> None: "FE_FLOATING_POINT_EQUALITY", "FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER", "ICAST_IDIV_CAST_TO_DOUBLE", + "ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT", "SA_FIELD_SELF_ASSIGNMENT", "UC_USELESS_CONDITION", "UC_USELESS_OBJECT", @@ -824,6 +825,7 @@ def main() -> None: "NP_LOAD_OF_KNOWN_NULL_VALUE", "NP_BOOLEAN_RETURN_NULL", "RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN", + "OS_OPEN_STREAM", "REFLC_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_CLASS", "REC_CATCH_EXCEPTION", "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", @@ -865,6 +867,8 @@ def _is_exempt(f: Finding) -> bool: return True if f.rule == "NN_NAKED_NOTIFY" and "Display.java" in loc: return True + if f.rule == "ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT" and "Deflate.java" in loc: + return True return False diff --git a/CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java b/CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java index b329e3adca..0fcad66206 100644 --- a/CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java +++ b/CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java @@ -3966,10 +3966,7 @@ public Rectangle getDisplaySafeArea(Rectangle rect) { * common constants in this class or be a user/implementation defined sound */ public void playBuiltinSound(String soundIdentifier) { - boolean played = playUserSound(soundIdentifier); - if (!played) { - return; - } + playUserSound(soundIdentifier); } /** @@ -3977,11 +3974,11 @@ public void playBuiltinSound(String soundIdentifier) { * * @param soundIdentifier the sound identifier which can match one of the * common constants in this class or be a user/implementation defined sound - * @return true if a user sound exists and was sent to playback */ - protected boolean playUserSound(String soundIdentifier) { - Object sound = builtinSounds.get(soundIdentifier); - return sound != null; + protected void playUserSound(String soundIdentifier) { + // TODO: Reintroduce builitin sound support + //Object sound = builtinSounds.get(soundIdentifier); + //return sound != null; //playAudio(sound); } diff --git a/CodenameOne/src/com/codename1/impl/CodenameOneThread.java b/CodenameOne/src/com/codename1/impl/CodenameOneThread.java index 66dd820798..021ed7a562 100644 --- a/CodenameOne/src/com/codename1/impl/CodenameOneThread.java +++ b/CodenameOne/src/com/codename1/impl/CodenameOneThread.java @@ -23,6 +23,7 @@ package com.codename1.impl; import com.codename1.io.Log; +import com.codename1.io.Util; import com.codename1.ui.Display; import java.io.DataInputStream; @@ -133,6 +134,8 @@ public void storeStackForException(Throwable t, int currentStackFrame) { * Prints the stack trace matching the given stack */ public String getStack(Throwable t) { + InputStream inp = null; + DataInputStream di = null; try { StringBuilder b = new StringBuilder(); int size; @@ -145,11 +148,11 @@ public String getStack(Throwable t) { } String[] stk = new String[size]; - InputStream inp = Display.getInstance().getResourceAsStream(getClass(), "/methodData.dat"); + inp = Display.getInstance().getResourceAsStream(getClass(), "/methodData.dat"); if (inp == null) { return t.toString(); } - DataInputStream di = new DataInputStream(inp); + di = new DataInputStream(inp); int totalAmount = di.readInt(); String lastClass = ""; for (int x = 0; x < totalAmount; x++) { @@ -172,6 +175,9 @@ public String getStack(Throwable t) { return b.toString(); } catch (IOException ex) { ex.printStackTrace(); + } finally { + Util.cleanup(di); + Util.cleanup(inp); } return "Failed in stack generation for " + t; } diff --git a/CodenameOne/src/com/codename1/testing/DeviceRunner.java b/CodenameOne/src/com/codename1/testing/DeviceRunner.java index 04c5405b7a..503e47336f 100644 --- a/CodenameOne/src/com/codename1/testing/DeviceRunner.java +++ b/CodenameOne/src/com/codename1/testing/DeviceRunner.java @@ -23,6 +23,7 @@ package com.codename1.testing; import com.codename1.io.Log; +import com.codename1.io.Util; import com.codename1.ui.CN; import com.codename1.ui.Display; @@ -48,8 +49,10 @@ public void runTests() { failedTests = 0; passedTests = 0; Log.p("-----STARTING TESTS-----"); + InputStream is = null; + DataInputStream di = null; try { - InputStream is = DeviceRunner.class.getResourceAsStream("/tests.dat"); + is = DeviceRunner.class.getResourceAsStream("/tests.dat"); if (is == null) { is = Display.getInstance().getResourceAsStream(null, "/tests.dat"); @@ -60,7 +63,7 @@ public void runTests() { System.exit(2); return; } - DataInputStream di = new DataInputStream(is); + di = new DataInputStream(is); int version = di.readInt(); if (version > VERSION) { Log.p("Tests were built with a new version of Codename One and can't be executed with this runner"); @@ -72,13 +75,16 @@ public void runTests() { for (int iter = 0; iter < tests.length; iter++) { tests[iter] = di.readUTF(); } - di.close(); + Util.cleanup(di); - for (int iter = 0; iter < tests.length; iter++) { - runTest(tests[iter]); + for (String test : tests) { + runTest(test); } } catch (IOException err) { TestReporting.getInstance().logException(err); + } finally { + Util.cleanup(is); + Util.cleanup(di); } TestReporting.getInstance().testExecutionFinished(getClass().getName()); if (failedTests > 0) { diff --git a/maven/core-unittests/spotbugs-exclude.xml b/maven/core-unittests/spotbugs-exclude.xml index 221cdb8d49..7626676ffb 100644 --- a/maven/core-unittests/spotbugs-exclude.xml +++ b/maven/core-unittests/spotbugs-exclude.xml @@ -151,6 +151,47 @@ + + + + + + + + + + + + + + + + + + +