Skip to content

Commit

Permalink
Merge pull request #33 from vorburger/errorprone
Browse files Browse the repository at this point in the history
Add Error Prone
  • Loading branch information
ianopolous authored Jan 7, 2025
2 parents eecfbae + b32e2d4 commit 55443f5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
20 changes: 17 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,24 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.13.0</version>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-Xlint:-serial,all</arg>
<arg>-Werror</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>--should-stop=ifError=FLOW</arg>
<arg>-Xplugin:ErrorProne</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.36.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/ipfs/cid/Cid.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/io/ipfs/cid/CidTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.ipfs.cid;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.IOException;
Expand Down Expand Up @@ -30,16 +31,17 @@ void validStrings() {
@Test
void emptyStringShouldFail() throws IOException {
try {
Cid cid = Cid.decode("");
Cid.decode("");
throw new RuntimeException();
} catch (IllegalStateException e) {
// Expected!
}
}

@Test
void basicMarshalling() throws Exception {
MessageDigest hasher = MessageDigest.getInstance("SHA-512");
byte[] hash = hasher.digest("TEST".getBytes());
byte[] hash = hasher.digest("TEST".getBytes(UTF_8));

Cid cid = new Cid(1, Cid.Codec.Raw, Multihash.Type.sha2_512, hash);
byte[] data = cid.toBytes();
Expand All @@ -65,9 +67,10 @@ void version0Handling() throws Exception {
void version0Error() throws Exception {
String invalidString = "QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zIII";
try {
Cid cid = Cid.decode(invalidString);
Cid.decode(invalidString);
throw new RuntimeException();
} catch (IllegalStateException e) {
// Expected!
}
}

Expand Down

0 comments on commit 55443f5

Please sign in to comment.