Skip to content

Commit d968b1b

Browse files
authored
Merge pull request #5818 from dizzzz/refactor/improve_build
[refactor] Address build warnings -Xlint
2 parents 6a2445a + 09f0d06 commit d968b1b

File tree

42 files changed

+122
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+122
-79
lines changed

exist-ant/src/main/java/org/exist/ant/AbstractXMLDBTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected void registerDatabase() throws BuildException
167167
}
168168

169169
final Class<?> clazz = Class.forName( driver );
170-
final Database database = (Database)clazz.newInstance();
170+
final Database database = (Database)clazz.getDeclaredConstructor().newInstance();
171171
database.setProperty( "create-database", createDatabase ? "true" : "false" );
172172
database.setProperty( "ssl-enable", ssl ? "true" : "false" );
173173

exist-ant/src/main/java/org/exist/ant/XMLDBXQueryTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.io.File;
3838
import java.io.IOException;
3939
import java.io.Writer;
40+
import java.net.URI;
4041
import java.net.URL;
4142
import java.nio.file.Files;
4243
import java.nio.file.Path;
@@ -115,7 +116,7 @@ public void execute() throws BuildException {
115116
final Resource resource = base.getResource(queryUri);
116117
source = new BinarySource((byte[]) resource.getContent(), true);
117118
} else {
118-
source = new URLSource(new URL(queryUri));
119+
source = new URLSource(URI.create(queryUri).toURL());
119120
}
120121
} else if (queryFile != null) {
121122
log("XQuery file " + queryFile.getAbsolutePath(), Project.MSG_DEBUG);

exist-ant/src/test/java/org/exist/ant/FileTaskTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
import java.net.URL;
3939

4040
import static org.hamcrest.CoreMatchers.containsString;
41+
import static org.hamcrest.MatcherAssert.assertThat;
4142
import static org.junit.Assert.assertEquals;
42-
import static org.junit.Assert.assertThat;
43+
4344

4445
public class FileTaskTest extends AbstractTaskTest {
4546

exist-ant/src/test/java/org/exist/ant/UserTaskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
import static org.hamcrest.CoreMatchers.containsString;
3232
import static org.hamcrest.CoreMatchers.not;
33+
import static org.hamcrest.MatcherAssert.assertThat;
3334
import static org.junit.Assert.assertEquals;
34-
import static org.junit.Assert.assertThat;
3535

3636
public class UserTaskTest extends AbstractTaskTest {
3737

exist-ant/src/test/java/org/exist/ant/XmldbTaskTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
import static java.nio.charset.StandardCharsets.UTF_8;
4545
import static org.hamcrest.CoreMatchers.containsString;
46+
import static org.hamcrest.MatcherAssert.assertThat;
4647
import static org.hamcrest.core.AllOf.allOf;
4748
import static org.junit.Assert.*;
4849

exist-core/src/test/java/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void testingGetReleaseCycle() {
103103
boolean debug = false;
104104
try {
105105
Configuration config = new Configuration();
106-
config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false));
106+
config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, Boolean.FALSE);
107107
BrokerPool.configure(1, 5, config);
108108

109109
Database db = BrokerPool.getInstance();

exist-parent/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,12 @@
698698
<version>3.14.0</version>
699699
<configuration>
700700
<encoding>${project.build.sourceEncoding}</encoding>
701+
<annotationProcessorPaths>
702+
<path>
703+
<groupId>com.google.code.findbugs</groupId>
704+
<artifactId>jsr305</artifactId>
705+
</path>
706+
</annotationProcessorPaths>
701707
</configuration>
702708
</plugin>
703709
<plugin>

extensions/exiftool/src/main/java/org/exist/exiftool/xquery/MetadataFunctions.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ private Sequence extractMetadataFromWebResource(String uri) throws XPathExceptio
154154
private Sequence exifToolExtract(final Path binaryFile) throws XPathException {
155155
final ExiftoolModule module = (ExiftoolModule) getParentModule();
156156
try {
157-
final Process p = Runtime.getRuntime().exec(module.getPerlPath() + " " + module.getExiftoolPath() + " -X -struct " + binaryFile.toAbsolutePath());
157+
final String[] command = new String[]{module.getPerlPath(), module.getExiftoolPath(), "-X", "-struct", binaryFile.toAbsolutePath().toString()};
158+
final Process p = Runtime.getRuntime().exec(command);
158159
try(final InputStream stdIn = p.getInputStream();
159-
final UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
160+
final UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
160161

161162
//buffer stdin
162163
baos.write(stdIn);
@@ -176,10 +177,11 @@ private Sequence exifToolExtract(final Path binaryFile) throws XPathException {
176177
private Sequence exifToolWebExtract(final URI uri) throws XPathException {
177178
final ExiftoolModule module = (ExiftoolModule) getParentModule();
178179
try {
179-
final Process p = Runtime.getRuntime().exec(module.getExiftoolPath()+" -fast -X -");
180+
final String[] command = new String[]{module.getExiftoolPath(), "-fast", "-X", "-"};
181+
final Process p = Runtime.getRuntime().exec(command);
180182

181183
try(final InputStream stdIn = p.getInputStream();
182-
final UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) {
184+
final UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
183185

184186
try(final OutputStream stdOut = p.getOutputStream()) {
185187
final Source src = SourceFactory.getSource(context.getBroker(), null, uri.toString(), false);

extensions/expath/src/main/java/org/expath/exist/ZipFileFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private Sequence updateZip(XmldbURI uri, String[] paths, BinaryValue[] binaries)
137137
binariesTable.put(paths[i], binaries[i]);
138138
}
139139

140-
try(final UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream())
140+
try(final UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get())
141141
{
142142
zis = zipFileSource.getStream();
143143
ZipOutputStream zos = new ZipOutputStream(baos); // zos is the output - the result

extensions/expath/src/main/java/org/expath/tools/model/exist/EXistSequence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void serialize(final OutputStream out, final SerialParameters params) thr
8282
props.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");
8383

8484
final String encoding = props.getProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name());
85-
try(final Writer writer = new OutputStreamWriter(new CloseShieldOutputStream(out), encoding)) {
85+
try(final Writer writer = new OutputStreamWriter(CloseShieldOutputStream.wrap(out), encoding)) {
8686
final XQuerySerializer xqSerializer = new XQuerySerializer(context.getBroker(), props, writer);
8787
xqSerializer.serialize(sequence);
8888
} catch(final SAXException | IOException | XPathException e) {

0 commit comments

Comments
 (0)