-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #997 from hcoles/bug/try-with-resource-empty-return
Bug/try with resource empty return
- Loading branch information
Showing
5 changed files
with
129 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...est/java/com/example/emptyreturns/AlreadyReturnsEmptyOptionalInTryWithResourcesBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.emptyreturns; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.util.Optional; | ||
|
||
public class AlreadyReturnsEmptyOptionalInTryWithResourcesBlock { | ||
public Optional<String> a() throws IOException { | ||
try(ByteArrayOutputStream os = new ByteArrayOutputStream()) { | ||
Double.parseDouble("12"); | ||
if (os.size() > 42) { | ||
return Optional.empty(); | ||
} | ||
return Optional.of("foo"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
pitest-entry/src/test/java/org/pitest/util/CurrentRuntime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.pitest.util; | ||
|
||
public class CurrentRuntime { | ||
|
||
public static int version() { | ||
String version = System.getProperty("java.version").replace("-ea", ""); | ||
if (version.startsWith("1.")) { | ||
version = version.substring(2, 3); | ||
} else { | ||
int dot = version.indexOf("."); | ||
if (dot != -1) { | ||
version = version.substring(0, dot); | ||
} | ||
} | ||
return Integer.parseInt(version); | ||
} | ||
} |
Binary file added
BIN
+1.36 KB
...leClasses/emptyReturns/AlreadyReturnsEmptyOptionalInTryWithResourcesBlock_javac.class.bin
Binary file not shown.