Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4259 support Java 11 #7514

Merged
merged 14 commits into from Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 2 additions & 23 deletions pom.xml
Expand Up @@ -43,7 +43,7 @@
Jacoco 0.8.2 seems to break Netbeans code coverage integration so we'll use 0.8.1 instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is no longer needed, no?

See https://github.com/jacoco/jacoco/issues/772 for discussion of how the XML changed.
-->
<jacoco.version>0.8.1</jacoco.version>
<jacoco.version>0.8.6</jacoco.version>
</properties>
<pluginRepositories>
<pluginRepository>
Expand Down Expand Up @@ -816,27 +816,6 @@
<id>all-unit-tests</id>
</profile>
<!-- TODO: Add a profile to run API tests (integration tests that end in IT.java. See conf/docker-aio/run-test-suite.sh -->
<profile>
<id>Java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- for use with `mvn -DcompilerArgument=-Xlint:unchecked compile` -->
<compilerArgument>${compilerArgument}</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Java9Plus</id>
<activation>
Expand All @@ -849,7 +828,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>8</release>
<release>11</release>
<!-- for use with `mvn -DcompilerArgument=-Xlint:unchecked compile` -->
<compilerArgument>${compilerArgument}</compilerArgument>
</configuration>
Expand Down
Expand Up @@ -250,11 +250,12 @@ public Response loadDatasetFields(File file) {
int lineNumber = 0;
HeaderType header = null;
JsonArrayBuilder responseArr = Json.createArrayBuilder();
String[] values = null;
try {
br = new BufferedReader(new FileReader("/" + file));
while ((line = br.readLine()) != null) {
lineNumber++;
String[] values = line.split(splitBy);
values = line.split(splitBy);
if (values[0].startsWith("#")) { // Header row
switch (values[0]) {
case "#metadataBlock":
Expand Down Expand Up @@ -301,7 +302,7 @@ public Response loadDatasetFields(File file) {
return error(Status.EXPECTATION_FAILED, "File not found");

} catch (ArrayIndexOutOfBoundsException e) {
String message = getArrayIndexOutOfBoundMessage(header, lineNumber, e);
String message = getArrayIndexOutOfBoundMessage(header, lineNumber, values.length);
logger.log(Level.WARNING, message, e);
alr.setActionResult(ActionLogRecord.Result.InternalError);
alr.setInfo(alr.getInfo() + "// " + message);
Expand Down Expand Up @@ -352,10 +353,9 @@ public String getGeneralErrorMessage(HeaderType header, int lineNumber, String m
*/
public String getArrayIndexOutOfBoundMessage(HeaderType header,
int lineNumber,
ArrayIndexOutOfBoundsException e) {
int wrongIndex) {

List<String> columns = getColumnsByHeader(header);
int wrongIndex = Integer.parseInt(e.getMessage());

String column = columns.get(wrongIndex - 1);
List<String> arguments = new ArrayList<>();
Expand Down
Expand Up @@ -43,7 +43,7 @@ public void testGeneralErrorMessageBundle() {
@Test
public void testGetArrayIndexOutOfBoundMessage() {
DatasetFieldServiceApi api = new DatasetFieldServiceApi();
String message = api.getArrayIndexOutOfBoundMessage(DatasetFieldServiceApi.HeaderType.DATASETFIELD, 5, new ArrayIndexOutOfBoundsException("4"));
String message = api.getArrayIndexOutOfBoundMessage(DatasetFieldServiceApi.HeaderType.DATASETFIELD, 5, 4);
assertEquals(
"Error parsing metadata block in DATASETFIELD part, line #5: missing 'watermark' column (#5)",
message
Expand Down
Expand Up @@ -62,24 +62,26 @@ public void testGetReadChannel() throws Exception {
@Test
public void testGetDvObject() {
assertEquals(null, instance.getDvObject());
instance.setDvObject(new Dataset());
assertEquals(new Dataset(), instance.getDataset());

try {
Dataset d= new Dataset();
instance.setDvObject(d);
//assertSame uses == rather than the .equals() method which would (currently) be true for any two Datasets
assertSame(d, instance.getDataset()); try {
instance.getDataFile();
fail("This should have thrown");
} catch (ClassCastException ex) {
assertEquals(ex.getMessage(), "edu.harvard.iq.dataverse.Dataset cannot be cast to edu.harvard.iq.dataverse.DataFile");
//Test succeeds
}
try {
instance.getDataverse();
fail("This should have thrown");
} catch (ClassCastException ex) {
assertEquals(ex.getMessage(), "edu.harvard.iq.dataverse.Dataset cannot be cast to edu.harvard.iq.dataverse.Dataverse");
//Test succeeds
}
// null driver defaults to 'file'
assertEquals(new DataFile(), new FileAccessIO<>(new DataFile(), null, null).getDataFile());
assertEquals(new Dataverse(), new FileAccessIO<>(new Dataverse(), null, null).getDataverse());
DataFile f= new DataFile();
Dataverse dv = new Dataverse();
assertSame(f, new FileAccessIO<>(f, null, null).getDataFile());
assertSame(dv, new FileAccessIO<>(dv, null, null).getDataverse());
}

@Test
Expand Down