Skip to content
Permalink
Browse files
Merge pull request #168 from lewismc/ANY23-461
[ANY23-461] Upgrade Any23 to JDK11
  • Loading branch information
lewismc committed Mar 27, 2021
2 parents 0b0538c + 4f84ee9 commit f70b3212ad0d963809435552b8150b7f46c543be
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 59 deletions.
@@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '1.8' ]
java: [ '11' ]

steps:
- uses: actions/checkout@v2
@@ -17,11 +17,12 @@

package org.apache.any23.extractor.rdf;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.StreamReadFeature;
import com.fasterxml.jackson.core.json.JsonReadFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.github.jsonldjava.core.JsonLdOptions;
import com.github.jsonldjava.core.JsonLdProcessor;
import com.github.jsonldjava.utils.JsonUtils;
@@ -45,23 +46,14 @@
*/
public class JSONLDExtractor extends BaseRDFExtractor {

private static final JsonFactory JSON_FACTORY = new JsonFactory(new ObjectMapper());

static {
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER);
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_COMMENTS); // handled by JsonCleaningInputStream
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_MISSING_VALUES); // handled by JsonCleaningInputStream
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS);
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_SINGLE_QUOTES); // handled by JsonCleaningInputStream
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_TRAILING_COMMA); // handled by JsonCleaningInputStream
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS);
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_YAML_COMMENTS); // handled by JsonCleaningInputStream
JSON_FACTORY.enable(JsonParser.Feature.IGNORE_UNDEFINED);
JSON_FACTORY.enable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
JSON_FACTORY.disable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION);
}
private static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder()
.enable(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER).disable(JsonReadFeature.ALLOW_JAVA_COMMENTS)
.disable(JsonReadFeature.ALLOW_MISSING_VALUES).enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS)
.enable(JsonReadFeature.ALLOW_LEADING_ZEROS_FOR_NUMBERS).disable(JsonReadFeature.ALLOW_SINGLE_QUOTES)
.disable(JsonReadFeature.ALLOW_TRAILING_COMMA).enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS)
.enable(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES).disable(JsonReadFeature.ALLOW_YAML_COMMENTS)
.enable(StreamReadFeature.IGNORE_UNDEFINED).enable(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION)
.disable(StreamReadFeature.STRICT_DUPLICATE_DETECTION).build();

/**
* @deprecated since 2.4. This extractor has never supported these settings. Use {@link #JSONLDExtractor()} instead.
@@ -95,7 +87,8 @@ public void run(ExtractionParameters extractionParameters, ExtractionContext ext
options.useNamespaces = true;

try {
Object json = JsonUtils.fromJsonParser(JSON_FACTORY.createParser(new JsonCleaningInputStream(in)));
Object json = JsonUtils
.fromJsonParser(OBJECT_MAPPER.getFactory().createParser(new JsonCleaningInputStream(in)));
JsonLdProcessor.toRDF(json, handler, options);
} catch (JsonProcessingException e) {
JsonLocation loc = e.getLocation();
@@ -198,18 +198,18 @@ public void testDemoCodeSnippet1() throws Exception {
public void testDemoCodeSnippet2() throws Exception {
assumeOnlineAllowed();

/* 1 */Any23 runner = new Any23();
/* 2 */runner.setHTTPUserAgent("apache-any23-test-user-agent");
/* 3 */HTTPClient httpClient = runner.getHTTPClient();
/* 4 */DocumentSource source = new HTTPDocumentSource(httpClient, "http://dbpedia.org/resource/Trento");
/* 5 */ByteArrayOutputStream out = new ByteArrayOutputStream();
/* 6 */TripleHandler handler = new NTriplesWriter(out);
Any23 runner = new Any23();
runner.setHTTPUserAgent("apache-any23-test-user-agent");
HTTPClient httpClient = runner.getHTTPClient();
DocumentSource source = new HTTPDocumentSource(httpClient, "http://dbpedia.org/resource/Trento");
ByteArrayOutputStream out = new ByteArrayOutputStream();
TripleHandler handler = new NTriplesWriter(out);
try {
/* 7 */runner.extract(source, handler);
runner.extract(source, handler);
} finally {
/* 8 */handler.close();
handler.close();
}
/* 9 */String n3 = out.toString("UTF-8");
String n3 = out.toString("UTF-8");

/*
* <http://dbpedia.org/resource/Trent> <http://dbpedia.org/ontology/wikiPageDisambiguates>
@@ -222,7 +222,7 @@ public void testDemoCodeSnippet2() throws Exception {
Assert.assertTrue(n3.length() > 0);

Assert.assertTrue(n3.contains(
"<http://dbpedia.org/resource/Trento> <http://dbpedia.org/property/mayor> \"Alessandro Andreatta\" ."));
"<http://dbpedia.org/resource/Trento> <http://dbpedia.org/property/mayor> \"Franco Ianeselli, elected 2020\"@en ."));
}

/**
37 pom.xml
@@ -257,8 +257,8 @@
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<javac.src.version>1.8</javac.src.version>
<javac.target.version>1.8</javac.target.version>
<javac.src.version>11</javac.src.version>
<javac.target.version>11</javac.target.version>

<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ssZ</maven.build.timestamp.format>
<implementation.build>${scmBranch}@r${buildNumber}</implementation.build>
@@ -274,7 +274,7 @@
<tika.version>1.24</tika.version>
<openie_2.11.version>4.2.6</openie_2.11.version>
<openregex.version>1.1.1</openregex.version>
<jackson.version>2.10.3</jackson.version>
<jackson.version>2.12.2</jackson.version>
<commons-io.version>2.6</commons-io.version>

<!-- Overridden in profiles to add JDK specific arguments to surefire -->
@@ -288,7 +288,7 @@
<form.tracker.id>UA-59636188-1</form.tracker.id>

<!-- Maven Plugin Versions -->
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
<maven-install-plugin.version>3.0.0-M1</maven-install-plugin.version>
@@ -298,7 +298,7 @@
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<buildnumber-maven-plugin.version>1.4</buildnumber-maven-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-jar-plugin.version>3.1.2</maven-jar-plugin.version>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
@@ -307,7 +307,7 @@
<maven-jxr-plugin.version>3.0.0</maven-jxr-plugin.version>
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
<apache-rat-plugin.version>0.13</apache-rat-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-war-plugin.version>3.2.3</maven-war-plugin.version>
<maven-invoker-plugin.version>3.2.1</maven-invoker-plugin.version>
@@ -510,7 +510,7 @@
<dependency>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java</artifactId>
<version>0.13.1</version>
<version>0.13.2</version>
</dependency>
<dependency>
<groupId>org.semarglproject</groupId>
@@ -747,8 +747,7 @@
<bundledSignature>jdk-unsafe-${javac.src.version}</bundledSignature>
<bundledSignature>jdk-deprecated-${javac.src.version}</bundledSignature>
<bundledSignature>jdk-non-portable</bundledSignature>
<!-- comment out until we upgrade past Java 8 -->
<!--bundledSignature>jdk-reflection</bundledSignature-->
<bundledSignature>jdk-reflection</bundledSignature>
<bundledSignature>jdk-internal-${javac.src.version}</bundledSignature>
<bundledSignature>jdk-system-out</bundledSignature>
<bundledSignature>commons-io-unsafe-${commons-io.version}</bundledSignature>
@@ -758,7 +757,7 @@
<execution>
<goals>
<goal>check</goal>
<!--goal>testCheck</goal-->
<goal>testCheck</goal>
</goals>
</execution>
</executions>
@@ -769,13 +768,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<!--
| Apple's JVM sometimes requires more memory
-->
<additionalJOption>-J-Xmx1024m</additionalJOption>
<source>8</source>
</configuration>
</plugin>

<!-- Drop inherited behavior (i.e. don't put any more default LICENSE and NOTICE files in all artifacts) -->
@@ -946,13 +938,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<!--
| Apple's JVM sometimes requires more memory
-->
<additionalJOption>-J-Xmx1024m</additionalJOption>
<source>8</source>
</configuration>
</plugin>

<!-- Browsable documentation. -->
@@ -1091,7 +1076,6 @@
<goal>jar</goal>
</goals>
<configuration>
<source>8</source>
<quiet>true</quiet>
<archive>
<manifest>
@@ -1185,9 +1169,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<source>8</source>
</configuration>
<reportSets>
<reportSet>
<reports>

0 comments on commit f70b321

Please sign in to comment.