Skip to content

Commit 27e9b8f

Browse files
authored
[ZEPPELIN-6276] Replace Deprecated Number Constructors for Java 11
### What is this PR for? This PR removes usages of deprecated Number constructors (e.g., `new Integer()`, `new Double()`, `new Long()`) and replaces them with factory methods such as `valueOf()` or `parseXxx()` methods. The goal is to improve Java 11 compatibility and eliminate compiler warnings related to deprecated APIs. ### What type of PR is it? Refactoring ### Todos * [x] - Replace deprecated constructors * [x] - Verify compatibility with Java 11 ### What is the Jira issue? [ZEPPELIN-6276](https://issues.apache.org/jira/browse/ZEPPELIN-6276) ### How should this be tested? ### Screenshots (if appropriate) ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes #5027 from celinayk/feature/replace-constructors. Signed-off-by: Philipp Dallig <[email protected]>
1 parent 215b782 commit 27e9b8f

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

rlang/src/main/java/org/apache/zeppelin/r/ZeppelinR.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ public class ZeppelinR {
4949
* Request to R repl
5050
*/
5151
private Request rRequestObject = null;
52-
private Integer rRequestNotifier = new Integer(0);
52+
private Integer rRequestNotifier = Integer.valueOf(0);
5353

5454
/**
5555
* Response from R repl
5656
*/
5757
private Object rResponseValue = null;
5858
private boolean rResponseError = false;
59-
private Integer rResponseNotifier = new Integer(0);
59+
private Integer rResponseNotifier = Integer.valueOf(0);
6060

6161
public ZeppelinR(RInterpreter rInterpreter) {
6262
this.rInterpreter = rInterpreter;

zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/KerberosInterpreter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ private Integer kinitFailThreshold() {
9595
//defined in zeppelin-env.sh, if not initialized then the default value is 5.
9696
if (System.getenv("KINIT_FAIL_THRESHOLD") != null) {
9797
try {
98-
kinitFailThreshold = new Integer(System.getenv("KINIT_FAIL_THRESHOLD"));
99-
} catch (Exception e) {
98+
kinitFailThreshold = Integer.valueOf(System.getenv("KINIT_FAIL_THRESHOLD"));
99+
} catch (NumberFormatException e) {
100100
LOGGER.error("Cannot get integer value from the given string, " + System
101101
.getenv("KINIT_FAIL_THRESHOLD") + " defaulting to " + kinitFailThreshold, e);
102102
}

zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceSetTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void testFilterByName() {
3030
ResourceSet set = new ResourceSet();
3131

3232
set.add(new Resource(null, new ResourceId("poo1", "resource1"), "value1"));
33-
set.add(new Resource(null, new ResourceId("poo1", "resource2"), new Integer(2)));
33+
set.add(new Resource(null, new ResourceId("poo1", "resource2"), Integer.valueOf(2)));
3434
assertEquals(2, set.filterByNameRegex(".*").size());
3535
assertEquals(1, set.filterByNameRegex("resource1").size());
3636
assertEquals(1, set.filterByNameRegex("resource2").size());
@@ -43,7 +43,7 @@ void testFilterByClassName() {
4343
ResourceSet set = new ResourceSet();
4444

4545
set.add(new Resource(null, new ResourceId("poo1", "resource1"), "value1"));
46-
set.add(new Resource(null, new ResourceId("poo1", "resource2"), new Integer(2)));
46+
set.add(new Resource(null, new ResourceId("poo1", "resource2"), Integer.valueOf(2)));
4747

4848
assertEquals(1, set.filterByClassnameRegex(".*String").size());
4949
assertEquals(1, set.filterByClassnameRegex(String.class.getName()).size());

zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/remote/AppendOutputRunner.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
public class AppendOutputRunner implements Runnable {
3838

3939
private static final Logger LOGGER = LoggerFactory.getLogger(AppendOutputRunner.class);
40-
public static final Long BUFFER_TIME_MS = new Long(100);
41-
private static final Long SAFE_PROCESSING_TIME = new Long(10);
42-
private static final Long SAFE_PROCESSING_STRING_SIZE = new Long(100000);
40+
public static final Long BUFFER_TIME_MS = Long.valueOf(100);
41+
private static final Long SAFE_PROCESSING_TIME = Long.valueOf(10);
42+
private static final Long SAFE_PROCESSING_STRING_SIZE = Long.valueOf(100000);
4343

4444
private final BlockingQueue<AppendOutputBuffer> queue = new LinkedBlockingQueue<>();
4545
private final RemoteInterpreterProcessListener listener;
@@ -90,7 +90,7 @@ public void run() {
9090
LOGGER.debug("Processing time for append-output took {} milliseconds", processingTime);
9191
}
9292

93-
Long sizeProcessed = new Long(0);
93+
Long sizeProcessed = Long.valueOf(0);
9494
for (Entry<String, StringBuilder> stringBufferMapEntry : stringBufferMap.entrySet()) {
9595
String stringBufferKey = stringBufferMapEntry.getKey();
9696
StringBuilder buffer = stringBufferMapEntry.getValue();

0 commit comments

Comments
 (0)