Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddenalpha committed Nov 23, 2024
1 parent aa51f10 commit 9c36c57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/cpp/windows/jssc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ JNIEXPORT jbyteArray JNICALL Java_jssc_SerialNativeInterface_readBytes
}

returnArray = env->NewByteArray(byteCount);
if( returnArray == NULL ){ goto Finally; }
if( returnArray == NULL ) goto Finally;

lpBuffer = (jbyte *)malloc(byteCount * sizeof(jbyte));
if(lpBuffer == NULL){
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/jssc/SerialNativeInterfaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.junit.Before;
import org.junit.Test;

import static java.lang.Integer.MAX_VALUE;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
Expand Down Expand Up @@ -96,7 +95,7 @@ public void throwsNpeIfPassedBufferIsNull() throws Exception {
}

@Test
public void throwsIaeIfCountNegative() throws Exception {
public void throwsIaeIfCountNegative() {
SerialNativeInterface testTarget = new SerialNativeInterface();
byte[] ret;
try{
Expand All @@ -115,13 +114,13 @@ public void throwsIaeIfCountNegative() throws Exception {
+" test run will just happily wait infinitely for those 2GiB to arrive"
+" at the stdin fd. Feel free to remove this test if you think it"
+" doesn't make sense to have it here.")
public void throwsOOMExIfRequestTooLarge() throws Exception {
public void throwsOOMExIfRequestTooLarge() {
SerialNativeInterface testTarget = new SerialNativeInterface();
try{
byte[] ret = testTarget.readBytes(0, MAX_VALUE);
byte[] ret = testTarget.readBytes(0, Integer.MAX_VALUE);
fail("Where's the exception?");
}catch( OutOfMemoryError ex ){
assertTrue(ex.getMessage().contains(String.valueOf(MAX_VALUE)));
assertTrue(ex.getMessage().contains(String.valueOf(Integer.MAX_VALUE)));
}
}

Expand Down

0 comments on commit 9c36c57

Please sign in to comment.