diff --git a/.classpath b/.classpath index 302947e..2576088 100644 --- a/.classpath +++ b/.classpath @@ -13,7 +13,7 @@ - + diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7af8a4f..a393341 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,7 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1b23554..310f5d2 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -38,11 +38,18 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v5 + + # setup Java 21 using Eclipse Temurin/Adoptium + - uses: actions/setup-java@v5 + with: + java-version: 21 + distribution: temurin + cache: maven # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +63,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v4 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +76,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 513cf76..a0ea775 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -7,16 +7,17 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 11 - uses: actions/setup-java@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v5 with: - java-version: '11' - distribution: 'adopt' + java-version: 21 + distribution: temurin + cache: maven - name: Analyze with sonarcloud - run: mvn --batch-mode verify sonar:sonar -Dsonar.projectKey=sebasbaumh_postgis-java-ng -Dsonar.organization=sebasbaumh -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} + run: mvn --batch-mode verify sonar:sonar -Dsonar.projectKey=sebasbaumh_postgis-java-ng -Dsonar.organization=sebasbaumh -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=${{ secrets.SONAR_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.project b/.project index 51e84ac..a90c195 100644 --- a/.project +++ b/.project @@ -39,4 +39,15 @@ edu.umd.cs.findbugs.plugin.eclipse.findbugsNature org.eclipse.wst.common.project.facet.core.nature + + + 1714375844981 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 711ae50..af7d083 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -4,16 +4,19 @@ org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=javax.annotation.ParametersAreNonnullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.notowning=org.eclipse.jdt.annotation.NotOwning org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +org.eclipse.jdt.core.compiler.annotation.owning=org.eclipse.jdt.annotation.Owning +org.eclipse.jdt.core.compiler.annotation.resourceanalysis=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.compliance=21 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -42,8 +45,10 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompatibleOwningContract=info org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.insufficientResourceAnalysis=warning org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled @@ -73,7 +78,7 @@ org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning -org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning @@ -83,7 +88,7 @@ org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warnin org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=info org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore @@ -92,7 +97,7 @@ org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled @@ -130,7 +135,8 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=21 +org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns=false org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line=false @@ -171,6 +177,7 @@ org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_record_components=16 org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 @@ -207,6 +214,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=nex org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block=next_line org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line @@ -233,6 +241,7 @@ org.eclipse.jdt.core.formatter.comment.indent_tag_description=false org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=do not insert org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags=false org.eclipse.jdt.core.formatter.comment.line_length=120 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true @@ -468,6 +477,7 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_line_comments=false org.eclipse.jdt.core.formatter.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs index 3355f41..1682f49 100644 --- a/.settings/org.eclipse.jdt.ui.prefs +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -139,5 +139,5 @@ cleanup_profile=_SB cleanup_settings_version=2 eclipse.preferences.version=1 formatter_profile=_SB -formatter_settings_version=22 +formatter_settings_version=23 org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 54a5299..d10bad0 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/README.md b/README.md index 6af5341..0233a75 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,11 @@ This project contains Java bindings for using [PostGIS](https://postgis.net/) ge * Recommended are PostgreSQL 15.1 and PostGIS 3.2.2 * Supported are versions starting from PostgreSQL 9.6 and PostGIS 2.3 * Support for current JDKs - * JDK 11 ([main branch](https://github.com/sebasbaumh/postgis-java-ng/tree/master), works also with JDK 17 applications) - * JDK 17 ([unreleased branch](https://github.com/sebasbaumh/postgis-java-ng/tree/jdk17), but already working) - * JDK 8 ([deprecated branch](https://github.com/sebasbaumh/postgis-java-ng/tree/jdk8)) + * JDK 21 ([main branch](https://github.com/sebasbaumh/postgis-java-ng/tree/master)) + * deprecated branches + * [JDK 17](https://github.com/sebasbaumh/postgis-java-ng/tree/jdk17) + * [JDK 11](https://github.com/sebasbaumh/postgis-java-ng/tree/jdk11) + * [JDK 8](https://github.com/sebasbaumh/postgis-java-ng/tree/jdk8) * The [license](https://github.com/sebasbaumh/postgis-java-ng/blob/master/LICENSE) is still LGPL * The authors are listed [here](https://github.com/sebasbaumh/postgis-java-ng/blob/master/AUTHORS) @@ -55,11 +57,11 @@ There is a Maven artifact in the official Maven repository, so just add this to io.github.sebasbaumh postgis-java-ng - 23.1.0 + 25.1.1 ``` -The version reflects the year of the release, e.g. `22.3.0` is a version released in 2022. +The version reflects the year of the release, e.g. `25.1.1` is a version released in 2024. The API differs a bit from [postgis-java](https://github.com/postgis/postgis-java) with the main point being a different namespace (`io.github.sebasbaumh.postgis`) as publishing a project to Maven Central requires to own that namespace. In addition the class structure is a bit different (see below) to support arc geometries and reduce boilerplate code, but you should be able to adapt to it easily. diff --git a/pom.xml b/pom.xml index 2bd9878..c6bd30e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.sebasbaumh postgis-java-ng - 23.2.0 + 25.1.2-SNAPSHOT jar PostGIS Java bindings @@ -30,18 +30,18 @@ scm:git:git://github.com/sebasbaumh/postgis-java-ng.git scm:git:ssh://github.com:sebasbaumh/postgis-java-ng.git https://github.com/sebasbaumh/postgis-java-ng/tree/master - v23.2.0 + v25.1.0 ossrh - https://oss.sonatype.org/content/repositories/snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + @@ -54,13 +54,13 @@ com.github.spotbugs spotbugs-annotations - 4.7.3 + 4.9.8 provided org.eclipse.jdt org.eclipse.jdt.annotation - 2.2.700 + 2.4.0 provided @@ -73,32 +73,32 @@ com.mchange c3p0 - 0.9.5.5 + 0.11.2 test com.mchange mchange-commons-java - 0.2.20 + 0.3.2 test org.slf4j slf4j-api - 2.0.7 + 2.0.17 test org.slf4j slf4j-jdk14 - 2.0.7 + 2.0.17 test org.postgresql postgresql - 42.6.0 + 42.7.8 @@ -106,10 +106,10 @@ maven-compiler-plugin - 3.11.0 + 3.14.1 - 11 - 11 + 21 + 21 -Xlint:all @@ -118,7 +118,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -133,7 +133,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 + 3.12.0 attach-javadocs @@ -141,8 +141,8 @@ jar - - 11 + + 21 none false @@ -153,7 +153,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.3.0 + 3.6.2 enforce-maven @@ -163,7 +163,7 @@ - 3.6 + 3.9 @@ -174,21 +174,21 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.4 org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.8 - - gpg2.exe + + org.apache.maven.plugins maven-release-plugin - 3.0.1 + 3.1.1 true false @@ -197,26 +197,25 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 + org.sonatype.central + central-publishing-maven-plugin + 0.9.0 true - ossrh - https://oss.sonatype.org/ - true + central + true org.apache.maven.plugins maven-dependency-plugin - 3.6.0 + 3.9.0 org.codehaus.mojo versions-maven-plugin - 2.16.0 + 2.19.1 diff --git a/postgis-java-ng dependencies.launch b/postgis-java-ng dependencies.launch index af9fff3..cdac615 100644 --- a/postgis-java-ng dependencies.launch +++ b/postgis-java-ng dependencies.launch @@ -17,5 +17,7 @@ + + diff --git a/postgis-java-ng only release (MacOS).launch b/postgis-java-ng only release (MacOS).launch new file mode 100644 index 0000000..44ce212 --- /dev/null +++ b/postgis-java-ng only release (MacOS).launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/postgis-java-ng only release.launch b/postgis-java-ng only release (Windows).launch similarity index 83% rename from postgis-java-ng only release.launch rename to postgis-java-ng only release (Windows).launch index e9ad89f..18291f2 100644 --- a/postgis-java-ng only release.launch +++ b/postgis-java-ng only release (Windows).launch @@ -19,5 +19,7 @@ + + diff --git a/postgis-java-ng package.launch b/postgis-java-ng package.launch index d95f10b..eaa1f9e 100644 --- a/postgis-java-ng package.launch +++ b/postgis-java-ng package.launch @@ -17,5 +17,7 @@ + + diff --git a/postgis-java-ng release (MacOS).launch b/postgis-java-ng release (MacOS).launch new file mode 100644 index 0000000..b89e616 --- /dev/null +++ b/postgis-java-ng release (MacOS).launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/postgis-java-ng release.launch b/postgis-java-ng release (Windows).launch similarity index 83% rename from postgis-java-ng release.launch rename to postgis-java-ng release (Windows).launch index 3f13b74..f442c2a 100644 --- a/postgis-java-ng release.launch +++ b/postgis-java-ng release (Windows).launch @@ -19,5 +19,7 @@ + + diff --git a/src/main/java/io/github/sebasbaumh/postgis/CompoundCurve.java b/src/main/java/io/github/sebasbaumh/postgis/CompoundCurve.java index f87f2f5..fb2a1e0 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/CompoundCurve.java +++ b/src/main/java/io/github/sebasbaumh/postgis/CompoundCurve.java @@ -127,9 +127,8 @@ public void close() public boolean equals(@Nullable Object other) { // check type and parent - if ((other instanceof CompoundCurve) && super.equals(other)) + if ((other instanceof CompoundCurve cother) && super.equals(other)) { - CompoundCurve cother = (CompoundCurve) other; return PostGisUtil.equalsIterable(this.subgeoms, cother.subgeoms); } return false; diff --git a/src/main/java/io/github/sebasbaumh/postgis/DriverWrapper.java b/src/main/java/io/github/sebasbaumh/postgis/DriverWrapper.java index fb351bb..c9458ef 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/DriverWrapper.java +++ b/src/main/java/io/github/sebasbaumh/postgis/DriverWrapper.java @@ -34,6 +34,7 @@ import org.eclipse.jdt.annotation.DefaultLocation; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Owning; import org.postgresql.Driver; import org.postgresql.PGConnection; @@ -210,9 +211,9 @@ public static void registerDataTypes(PGConnection pgconn) throws SQLException private static PGConnection tryUnwrap(Connection conn) throws SQLException { // short cut - if (conn instanceof PGConnection) + if (conn instanceof PGConnection pgconnection) { - return (PGConnection) conn; + return pgconnection; } // try to get underlying PostgreSQL connection if (conn.isWrapperFor(PGConnection.class)) @@ -261,6 +262,7 @@ public boolean acceptsURL(@SuppressWarnings("null") @Nonnull String url) * @see org.postgresql.Driver */ @Nullable + @Owning @Override public java.sql.Connection connect(@SuppressWarnings("null") @Nonnull String url, @SuppressWarnings("null") @Nonnull Properties info) throws SQLException @@ -271,10 +273,10 @@ public java.sql.Connection connect(@SuppressWarnings("null") @Nonnull String url { // connect to URL Connection result = super.connect(mangledURL, info); - if (result instanceof PGConnection) + if (result instanceof PGConnection pgconnection) { // add geometry and box types - registerDataTypes((PGConnection) result); + registerDataTypes(pgconnection); } return result; } diff --git a/src/main/java/io/github/sebasbaumh/postgis/LineString.java b/src/main/java/io/github/sebasbaumh/postgis/LineString.java index 7223d32..5ede87c 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/LineString.java +++ b/src/main/java/io/github/sebasbaumh/postgis/LineString.java @@ -136,9 +136,8 @@ public void close() public boolean equals(@Nullable Object other) { // check type and parent - if ((other instanceof LineString) && super.equals(other)) + if ((other instanceof LineString ls) && super.equals(other)) { - LineString ls = (LineString) other; // check all points return PostGisUtil.equalsIterable(this.points, ls.points); } diff --git a/src/main/java/io/github/sebasbaumh/postgis/MultiCurve.java b/src/main/java/io/github/sebasbaumh/postgis/MultiCurve.java index 1109f99..6dda5ef 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/MultiCurve.java +++ b/src/main/java/io/github/sebasbaumh/postgis/MultiCurve.java @@ -71,9 +71,9 @@ public double length() double d = 0; for (Geometry ls : subgeoms) { - if (ls instanceof LineBasedGeometry) + if (ls instanceof LineBasedGeometry lbg) { - d += ((LineBasedGeometry) ls).length(); + d += lbg.length(); } } return d; diff --git a/src/main/java/io/github/sebasbaumh/postgis/MultiGeometry.java b/src/main/java/io/github/sebasbaumh/postgis/MultiGeometry.java index cb48009..694b4a9 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/MultiGeometry.java +++ b/src/main/java/io/github/sebasbaumh/postgis/MultiGeometry.java @@ -102,9 +102,8 @@ public boolean checkConsistency() public boolean equals(@Nullable Object other) { // check type and parent - if ((other instanceof MultiGeometry) && super.equals(other)) + if ((other instanceof MultiGeometry cother) && super.equals(other)) { - MultiGeometry cother = (MultiGeometry) other; return PostGisUtil.equalsIterable(this.subgeoms, cother.subgeoms); } return false; diff --git a/src/main/java/io/github/sebasbaumh/postgis/PGbox2d.java b/src/main/java/io/github/sebasbaumh/postgis/PGbox2d.java index 69c74d5..76879fd 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PGbox2d.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PGbox2d.java @@ -68,9 +68,9 @@ public PGbox2d(String value) throws SQLException } @Override - public PGbox2d clone() + public PGbox2d clone() throws CloneNotSupportedException { - return new PGbox2d(llb.copy(), urt.copy()); + return (PGbox2d)super.clone(); } @Override diff --git a/src/main/java/io/github/sebasbaumh/postgis/PGbox3d.java b/src/main/java/io/github/sebasbaumh/postgis/PGbox3d.java index fb81d09..b1fdf0b 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PGbox3d.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PGbox3d.java @@ -68,9 +68,9 @@ public PGbox3d(String value) throws SQLException } @Override - public PGbox3d clone() + public PGbox3d clone() throws CloneNotSupportedException { - return new PGbox3d(llb.copy(), urt.copy()); + return (PGbox3d)super.clone(); } @Override diff --git a/src/main/java/io/github/sebasbaumh/postgis/PGboxbase.java b/src/main/java/io/github/sebasbaumh/postgis/PGboxbase.java index e2c9c51..eb47e92 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PGboxbase.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PGboxbase.java @@ -148,6 +148,16 @@ private static Point pointFromWKT(String wkt) return new Point(x, y); } + @Override + public PGboxbase clone() throws CloneNotSupportedException + { + PGboxbase o = (PGboxbase) super.clone(); + o.setType(this.getType()); + o.llb = llb.copy(); + o.urt = urt.copy(); + return o; + } + @Override public boolean equals(@Nullable Object obj) { diff --git a/src/main/java/io/github/sebasbaumh/postgis/PGgeography.java b/src/main/java/io/github/sebasbaumh/postgis/PGgeography.java index e758b83..1bedd29 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PGgeography.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PGgeography.java @@ -67,9 +67,9 @@ public PGgeography(String value) throws SQLException } @Override - public Object clone() + public PGgeography clone() throws CloneNotSupportedException { - return new PGgeography(geometry); + return (PGgeography) super.clone(); } } diff --git a/src/main/java/io/github/sebasbaumh/postgis/PGgeometry.java b/src/main/java/io/github/sebasbaumh/postgis/PGgeometry.java index 6666286..6b72ab2 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PGgeometry.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PGgeometry.java @@ -67,9 +67,9 @@ public PGgeometry(String value) throws SQLException } @Override - public Object clone() + public PGgeometry clone() throws CloneNotSupportedException { - return new PGgeometry(geometry); + return (PGgeometry) super.clone(); } } diff --git a/src/main/java/io/github/sebasbaumh/postgis/PGgeometrybase.java b/src/main/java/io/github/sebasbaumh/postgis/PGgeometrybase.java index 1af2e2c..f331ee3 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PGgeometrybase.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PGgeometrybase.java @@ -94,6 +94,15 @@ protected PGgeometrybase(String type, String value) throws SQLException setValue(value); } + @Override + public PGgeometrybase clone() throws CloneNotSupportedException + { + PGgeometrybase o = (PGgeometrybase) super.clone(); + o.setType(this.getType()); + o.setGeometry(this.getGeometry()); + return o; + } + @Override public boolean equals(@Nullable Object obj) { diff --git a/src/main/java/io/github/sebasbaumh/postgis/Point.java b/src/main/java/io/github/sebasbaumh/postgis/Point.java index 68cfce2..79b5ad1 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/Point.java +++ b/src/main/java/io/github/sebasbaumh/postgis/Point.java @@ -160,9 +160,9 @@ public double distance(Point p) public boolean equals(@Nullable Object other) { // check type and parent - if ((other instanceof Point) && super.equals(other)) + if ((other instanceof Point p) && super.equals(other)) { - return coordsAreEqual((Point) other); + return coordsAreEqual(p); } return false; } diff --git a/src/main/java/io/github/sebasbaumh/postgis/PolygonBase.java b/src/main/java/io/github/sebasbaumh/postgis/PolygonBase.java index ea5ba60..90d28cb 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PolygonBase.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PolygonBase.java @@ -155,9 +155,8 @@ private T createRing(Class clazzRing) public boolean equals(@Nullable Object other) { // check type and parent - if ((other instanceof PolygonBase) && super.equals(other)) + if ((other instanceof PolygonBase poly) && super.equals(other)) { - PolygonBase poly = (PolygonBase) other; return PostGisUtil.equalsIterable(this.rings, poly.rings); } return false; diff --git a/src/main/java/io/github/sebasbaumh/postgis/PostGisUtil.java b/src/main/java/io/github/sebasbaumh/postgis/PostGisUtil.java index 58f952a..5f4fa3a 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/PostGisUtil.java +++ b/src/main/java/io/github/sebasbaumh/postgis/PostGisUtil.java @@ -45,7 +45,7 @@ public final class PostGisUtil /** * Epsilon/tolerance for comparing double values. */ - private static double EPSILON = 1e-15; + private static final double EPSILON = 1e-15; /** * Characters for converting data to hex strings. */ diff --git a/src/main/java/io/github/sebasbaumh/postgis/binary/BinaryWriter.java b/src/main/java/io/github/sebasbaumh/postgis/binary/BinaryWriter.java index a35c2ad..310ad3e 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/binary/BinaryWriter.java +++ b/src/main/java/io/github/sebasbaumh/postgis/binary/BinaryWriter.java @@ -229,9 +229,9 @@ private static void writePolygon(PolygonBase geom, ValueSet for (T ring : rings) { // polygon linear rings are just written as a plain set of points - if (ring instanceof LinearRing) + if (ring instanceof LinearRing lr) { - writePoints((LinearRing) ring, dest); + writePoints(lr, dest); } else { diff --git a/src/main/java/io/github/sebasbaumh/postgis/binary/ValueGetter.java b/src/main/java/io/github/sebasbaumh/postgis/binary/ValueGetter.java index 71e9344..0badf44 100644 --- a/src/main/java/io/github/sebasbaumh/postgis/binary/ValueGetter.java +++ b/src/main/java/io/github/sebasbaumh/postgis/binary/ValueGetter.java @@ -34,27 +34,26 @@ public abstract class ValueGetter /** * Int builder for big endian encoding. */ - private static final IntBuilder INT_BUILDER_BIG_ENDIAN = (b1, b2, b3, b4) -> { - return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4; - }; + private static final IntBuilder INT_BUILDER_BIG_ENDIAN = (b1, b2, b3, b4) -> + (b1 << 24) + (b2 << 16) + (b3 << 8) + b4; + /** * Int builder for little endian encoding. */ - private static final IntBuilder INT_BUILDER_LITTLE_ENDIAN = (b1, b2, b3, b4) -> { - return (b4 << 24) + (b3 << 16) + (b2 << 8) + b1; - }; + private static final IntBuilder INT_BUILDER_LITTLE_ENDIAN = (b1, b2, b3, b4) -> + (b4 << 24) + (b3 << 16) + (b2 << 8) + b1; + /** * Int builder for big endian encoding. */ - private static final LongBuilder LONG_BUILDER_BIG_ENDIAN = (b1, b2, b3, b4, b5, b6, b7, b8) -> { - return (b1 << 56) + (b2 << 48) + (b3 << 40) + (b4 << 32) + (b5 << 24) + (b6 << 16) + (b7 << 8) + b8; - }; + private static final LongBuilder LONG_BUILDER_BIG_ENDIAN = (b1, b2, b3, b4, b5, b6, b7, b8) -> + (b1 << 56) + (b2 << 48) + (b3 << 40) + (b4 << 32) + (b5 << 24) + (b6 << 16) + (b7 << 8) + b8; + /** * Int builder for little endian encoding. */ - private static final LongBuilder LONG_BUILDER_LITTLE_ENDIAN = (b1, b2, b3, b4, b5, b6, b7, b8) -> { - return (b8 << 56) + (b7 << 48) + (b6 << 40) + (b5 << 32) + (b4 << 24) + (b3 << 16) + (b2 << 8) + b1; - }; + private static final LongBuilder LONG_BUILDER_LITTLE_ENDIAN = (b1, b2, b3, b4, b5, b6, b7, b8) -> + (b8 << 56) + (b7 << 48) + (b6 << 40) + (b5 << 32) + (b4 << 24) + (b3 << 16) + (b2 << 8) + b1; /** * Current encoding (default is little endian encoding). diff --git a/src/test/java/io/github/sebasbaumh/postgis/BoxesTest.java b/src/test/java/io/github/sebasbaumh/postgis/BoxesTest.java index d817556..7f18d67 100644 --- a/src/test/java/io/github/sebasbaumh/postgis/BoxesTest.java +++ b/src/test/java/io/github/sebasbaumh/postgis/BoxesTest.java @@ -26,11 +26,30 @@ import org.junit.Assert; import org.junit.Test; +import org.postgresql.util.PGobject; @SuppressWarnings({ "javadoc", "static-method" }) public class BoxesTest { + private static void cloneTest(T o) + { + try + { + Object o2 = o.clone(); + Assert.assertEquals(o.getClass(), o2.getClass()); + @SuppressWarnings("unchecked") + T t2 = (T) o2; + Assert.assertEquals(o, o2); + Assert.assertEquals(o.getType(), t2.getType()); + Assert.assertNotSame(o, o2); + } + catch (CloneNotSupportedException ex) + { + Assert.fail("Clone not supported: " + ex.getMessage()); + } + } + @Test public void testBox2d() throws SQLException { @@ -81,4 +100,12 @@ public void testBox3d_2() throws SQLException Assert.assertFalse(p1.is3d()); } + @Test + public void testClone() throws SQLException + { + cloneTest(new PGbox2d("BOX(1 2,3 4)")); + cloneTest(new PGbox3d("BOX3D(1 2 3,4 5 6)")); + cloneTest(new PGbox3d("BOX3D(1 2,4 5)")); + } + } \ No newline at end of file diff --git a/src/test/java/io/github/sebasbaumh/postgis/DatabaseTestBase.java b/src/test/java/io/github/sebasbaumh/postgis/DatabaseTestBase.java index 5f7ba04..b3c5ec8 100644 --- a/src/test/java/io/github/sebasbaumh/postgis/DatabaseTestBase.java +++ b/src/test/java/io/github/sebasbaumh/postgis/DatabaseTestBase.java @@ -31,6 +31,7 @@ import javax.sql.DataSource; +import org.eclipse.jdt.annotation.Owning; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -108,6 +109,7 @@ protected void beforeDatabaseShutdown() throws SQLException * @return {@link Connection} * @throws SQLException */ + @Owning protected Connection getConnection() throws SQLException { Assert.assertNotNull("the following properties need to be configured for using a connection: " + CONFIG_JDBC_URL @@ -203,6 +205,7 @@ protected Geometry getGeometryFromWKT(String wkt) throws SQLException * @return {@link DataSource} * @throws SQLException */ + @Owning protected DataSource getPooledDataSource() throws SQLException { Assert.assertNotNull("the following properties need to be configured for using a connection: " + CONFIG_JDBC_URL diff --git a/src/test/java/io/github/sebasbaumh/postgis/DatatypesTest.java b/src/test/java/io/github/sebasbaumh/postgis/DatatypesTest.java index eb601ce..ed36cb7 100644 --- a/src/test/java/io/github/sebasbaumh/postgis/DatatypesTest.java +++ b/src/test/java/io/github/sebasbaumh/postgis/DatatypesTest.java @@ -32,21 +32,21 @@ public class DatatypesTest extends DatabaseTestBase { - private static final String cr_str = "CIRCULARSTRING(-9 2,-8 3,-7 2)"; + private static final String CR_STR = "CIRCULARSTRING(-9 2,-8 3,-7 2)"; - private static final String cr_str2 = "CIRCULARSTRING(0 -1,-1 0,0 1,1 0,0 -1)"; + private static final String CR_STR2 = "CIRCULARSTRING(0 -1,-1 0,0 1,1 0,0 -1)"; - private static final String lng_str = "LINESTRING (10 10 20,20 20 20, 50 50 50, 34 34 34)"; + private static final String LNG_STR = "LINESTRING (10 10 20,20 20 20, 50 50 50, 34 34 34)"; private static final Logger logger = LoggerFactory.getLogger(DatatypesTest.class); - private static final String mlng_str = "MULTILINESTRING ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; + private static final String MLNG_STR = "MULTILINESTRING ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; - private static final String mplg_str = "MULTIPOLYGON (((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"; + private static final String MPLG_STR = "MULTIPOLYGON (((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"; - private static final String plg_str = "POLYGON ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; + private static final String PLG_STR = "POLYGON ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; - private static final String ptg_str = "POINT(10 10 20)"; + private static final String PTG_STR = "POINT(10 10 20)"; @SuppressWarnings("unchecked") private T assertGeometry(Class clazz, String wkt) throws SQLException @@ -68,8 +68,8 @@ public void testCircularString() throws SQLException return; } logger.trace("void testCircularString()"); - logger.debug(cr_str); - CircularString lng = assertGeometry(CircularString.class, cr_str); + logger.debug(CR_STR); + CircularString lng = assertGeometry(CircularString.class, CR_STR); logger.debug(lng.toString()); } @@ -81,8 +81,8 @@ public void testCircularString2() throws SQLException return; } logger.trace("void testCircularString2()"); - logger.debug(cr_str2); - CircularString lng = assertGeometry(CircularString.class, cr_str2); + logger.debug(CR_STR2); + CircularString lng = assertGeometry(CircularString.class, CR_STR2); logger.debug(lng.toString()); } @@ -94,8 +94,8 @@ public void testLineString() throws SQLException return; } logger.trace("void testLineString()"); - logger.debug(lng_str); - LineString lng = assertGeometry(LineString.class, lng_str); + logger.debug(LNG_STR); + LineString lng = assertGeometry(LineString.class, LNG_STR); logger.debug(lng.toString()); } @@ -107,8 +107,8 @@ public void testMultiLineString() throws SQLException return; } logger.trace("void testMultiLineString()"); - logger.debug(mlng_str); - MultiLineString mlng = assertGeometry(MultiLineString.class, mlng_str); + logger.debug(MLNG_STR); + MultiLineString mlng = assertGeometry(MultiLineString.class, MLNG_STR); logger.debug(mlng.toString()); } @@ -120,8 +120,8 @@ public void testMultiPolygon() throws SQLException return; } logger.trace("void testMultiPolygon()"); - logger.debug(mplg_str); - MultiPolygon mplg = assertGeometry(MultiPolygon.class, mplg_str); + logger.debug(MPLG_STR); + MultiPolygon mplg = assertGeometry(MultiPolygon.class, MPLG_STR); logger.debug(mplg.toString()); } @@ -133,8 +133,8 @@ public void testPGgeometry() throws SQLException return; } logger.trace("void testPGgeometry()"); - logger.debug(mlng_str); - PGgeometry pgf = new PGgeometry(getWKBFromWKT(mlng_str)); + logger.debug(MLNG_STR); + PGgeometry pgf = new PGgeometry(getWKBFromWKT(MLNG_STR)); logger.debug(pgf.toString()); } @@ -146,8 +146,8 @@ public void testPoint() throws SQLException return; } logger.trace("void testPoint()"); - logger.debug(ptg_str); - Point ptg = assertGeometry(Point.class, ptg_str); + logger.debug(PTG_STR); + Point ptg = assertGeometry(Point.class, PTG_STR); logger.debug(ptg.toString()); } @@ -159,8 +159,8 @@ public void testPolygon() throws SQLException return; } logger.trace("void testPolygon()"); - logger.debug(plg_str); - Polygon plg = assertGeometry(Polygon.class, plg_str); + logger.debug(PLG_STR); + Polygon plg = assertGeometry(Polygon.class, PLG_STR); logger.debug(plg.toString()); } diff --git a/src/test/java/io/github/sebasbaumh/postgis/EmptyGeometriesTest.java b/src/test/java/io/github/sebasbaumh/postgis/EmptyGeometriesTest.java index a3810fa..14b3826 100644 --- a/src/test/java/io/github/sebasbaumh/postgis/EmptyGeometriesTest.java +++ b/src/test/java/io/github/sebasbaumh/postgis/EmptyGeometriesTest.java @@ -99,6 +99,7 @@ protected void beforeDatabaseShutdown() throws SQLException } @Test + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("SQL_INJECTION_JDBC") public void testSqlStatements() throws SQLException { if (!hasDatabase()) @@ -120,7 +121,6 @@ public void testSqlStatements() throws SQLException logger.debug("returned resultSetObject {} => (class=[{}]) {}", i, resultSetObject.getClass().getName(), resultSetObject); } - resultSet.close(); } } } diff --git a/src/test/java/io/github/sebasbaumh/postgis/GeographyTest.java b/src/test/java/io/github/sebasbaumh/postgis/GeographyTest.java index a71cd81..1760880 100644 --- a/src/test/java/io/github/sebasbaumh/postgis/GeographyTest.java +++ b/src/test/java/io/github/sebasbaumh/postgis/GeographyTest.java @@ -33,15 +33,15 @@ @SuppressWarnings("javadoc") public class GeographyTest extends PostgisDatabaseTest { - private static final String lng_str = "LINESTRING (10 10 20,20 20 20, 50 50 50, 34 34 34)"; + private static final String LNG_STR = "LINESTRING (10 10 20,20 20 20, 50 50 50, 34 34 34)"; - private static final String mlng_str = "MULTILINESTRING ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; + private static final String MLNG_STR = "MULTILINESTRING ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; - private static final String mplg_str = "MULTIPOLYGON (((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"; + private static final String MPLG_STR = "MULTIPOLYGON (((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"; - private static final String plg_str = "POLYGON ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; + private static final String PLG_STR = "POLYGON ((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"; - private static final String ptg_str = "POINT(10 10 20)"; + private static final String PTG_STR = "POINT(10 10 20)"; @SuppressWarnings("unchecked") private T assertGeometry(Class clazz, String wkt) throws SQLException @@ -62,7 +62,7 @@ public void testLineString() throws SQLException { return; } - assertGeometry(LineString.class, lng_str); + assertGeometry(LineString.class, LNG_STR); } @Test @@ -72,7 +72,7 @@ public void testMultiLineString() throws SQLException { return; } - assertGeometry(MultiLineString.class, mlng_str); + assertGeometry(MultiLineString.class, MLNG_STR); } @Test @@ -82,7 +82,7 @@ public void testMultiPolygon() throws SQLException { return; } - assertGeometry(MultiPolygon.class, mplg_str); + assertGeometry(MultiPolygon.class, MPLG_STR); } @SuppressWarnings("unused") @@ -94,7 +94,7 @@ public void testPGgeometry() throws SQLException { return; } - new PGgeometry(getWKBFromWKT(mlng_str)); + new PGgeometry(getWKBFromWKT(MLNG_STR)); } @Test @@ -104,7 +104,7 @@ public void testPoint() throws SQLException { return; } - assertGeometry(Point.class, ptg_str); + assertGeometry(Point.class, PTG_STR); } @Test @@ -114,7 +114,7 @@ public void testPolygon() throws SQLException { return; } - assertGeometry(Polygon.class, plg_str); + assertGeometry(Polygon.class, PLG_STR); } } diff --git a/src/test/java/io/github/sebasbaumh/postgis/ParserTest.java b/src/test/java/io/github/sebasbaumh/postgis/ParserTest.java index 024340b..dfd31ec 100644 --- a/src/test/java/io/github/sebasbaumh/postgis/ParserTest.java +++ b/src/test/java/io/github/sebasbaumh/postgis/ParserTest.java @@ -347,7 +347,8 @@ public void testParserUsingDb() throws Exception } /** Pass a geometry representation through the SQL server */ - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE") + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({ "SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE", + "SQL_INJECTION_JDBC" }) private Geometry viaSQL(String rep) throws SQLException { logger.trace("Geometry viaSQL(String rep)"); diff --git a/src/test/java/io/github/sebasbaumh/postgis/VersionPrinterTest.java b/src/test/java/io/github/sebasbaumh/postgis/VersionPrinterTest.java index 14879aa..1044136 100644 --- a/src/test/java/io/github/sebasbaumh/postgis/VersionPrinterTest.java +++ b/src/test/java/io/github/sebasbaumh/postgis/VersionPrinterTest.java @@ -43,7 +43,7 @@ public class VersionPrinterTest extends DatabaseTestBase private static final Logger logger = LoggerFactory.getLogger(VersionPrinterTest.class); - private static String[] POSTGIS_FUNCTIONS = { "postgis_version", "postgis_proj_version", + private static final String[] POSTGIS_FUNCTIONS = { "postgis_version", "postgis_proj_version", "postgis_scripts_installed", "postgis_lib_version", "postgis_scripts_released", "postgis_uses_stats", "postgis_geos_version", "postgis_scripts_build_date", "postgis_lib_build_date", "postgis_full_version", "postgis_gdal_version", "postgis_libjson_version", "postgis_libxml_version", "postgis_raster_lib_version", @@ -119,6 +119,7 @@ private String getVersionString(String function) throws SQLException } @Test + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("CRLF_INJECTION_LOGS") public void test() throws Exception { if (!hasDatabase()) @@ -152,19 +153,16 @@ public void test() throws Exception // Print PostgreSQL server versions Assert.assertNotNull(connection); - try (Statement statement = connection.createStatement()) - { - logger.info("*** PostgreSQL Server ***"); - String versionString = getVersionString("version"); - logger.info("\t version: {}", versionString); + logger.info("*** PostgreSQL Server ***"); + String versionString = getVersionString("version"); + logger.info("\t version: {}", versionString); - // Print PostGIS versions - logger.info("*** PostGIS Server ***"); - for (String GISVERSION : POSTGIS_FUNCTIONS) - { - versionString = getVersionString(GISVERSION); - logger.info("\t {} version: {}", GISVERSION, versionString); - } + // Print PostGIS versions + logger.info("*** PostGIS Server ***"); + for (String GISVERSION : POSTGIS_FUNCTIONS) + { + versionString = getVersionString(GISVERSION); + logger.info("\t {} version: {}", GISVERSION, versionString); } }