Skip to content

Commit

Permalink
Properly enabling Error Prone and disabling its usage in community mo…
Browse files Browse the repository at this point in the history
…dules
  • Loading branch information
aaime committed Dec 30, 2018
1 parent 80e59fd commit 1de976d
Show file tree
Hide file tree
Showing 56 changed files with 182 additions and 138 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ notifications:
matrix: matrix:
include: include:
- jdk: oraclejdk8 - jdk: oraclejdk8
env: ARGS="-Dfmt.skip=true" env: ARGS="-Dfmt.skip=true" COMMUNITY_ARGS=$ARGS
- jdk: oraclejdk11 - jdk: oraclejdk11
env: ARGS="-Dfmt.skip=true" env: ARGS="-Dfmt.skip=true" COMMUNITY_ARGS=$ARGS
- jdk: oraclejdk11 - jdk: oraclejdk11
env: ARGS="-Dfmt.action=check -Ppmd -Perrorprone -DskipTests=true" env: ARGS="-Dfmt.action=check -Ppmd -Perrorprone -DskipTests=true" COMMUNITY_ARGS="-Dfmt.action=check -DskipTests=true"


Original file line number Original file line Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void testConnectionNotSharedIfTransactionIsNot() throws Exception {
* @throws Exception * @throws Exception
*/ */
@Test @Test
@SuppressWarnings("TryFailThrowable")
public void testNoConnectionLeakIfExceptionThrown() throws Exception { public void testNoConnectionLeakIfExceptionThrown() throws Exception {
FilterFactoryImplNamespaceAware ff = new FilterFactoryImplNamespaceAware(); FilterFactoryImplNamespaceAware ff = new FilterFactoryImplNamespaceAware();
ff.setNamepaceContext(mappingFs.getMapping().getNamespaces()); ff.setNamepaceContext(mappingFs.getMapping().getNamespaces());
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void onSetUp(org.geoserver.data.test.SystemTestData testData) throws E
} }


@Override @Override
@SuppressWarnings("deprecated") @SuppressWarnings("deprecation")
protected void onTearDown(SystemTestData testData) throws Exception { protected void onTearDown(SystemTestData testData) throws Exception {
super.onTearDown(testData); super.onTearDown(testData);
DataAccessRegistry.unregisterAll(); DataAccessRegistry.unregisterAll();
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void createTables(Map<String, File> propertyFiles, String parser)
// be supported if present. // be supported if present.
Geometry geom = (Geometry) value; Geometry geom = (Geometry) value;
value = value =
new WKTWriter(geom.getCoordinate().z == Double.NaN ? 2 : 3) new WKTWriter(Double.isNaN(geom.getCoordinate().z) ? 2 : 3)
.write(geom); .write(geom);
} }
if (value == null || value.toString().equalsIgnoreCase("null")) { if (value == null || value.toString().equalsIgnoreCase("null")) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void createTables(Map<String, File> propertyFiles)
// be supported if present. // be supported if present.
Geometry geom = (Geometry) value; Geometry geom = (Geometry) value;
value = value =
new WKTWriter(geom.getCoordinate().z == Double.NaN ? 2 : 3) new WKTWriter(Double.isNaN(geom.getCoordinate().z) ? 2 : 3)
.write(geom); .write(geom);
} }
if (value == null || value.toString().equalsIgnoreCase("null")) { if (value == null || value.toString().equalsIgnoreCase("null")) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void setUp() throws Exception {
XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));
} }


@Test
public void testEncodeBrief() throws Exception { public void testEncodeBrief() throws Exception {
// setup the request // setup the request
CSWRecordsResult response = getCSWResponse(); CSWRecordsResult response = getCSWResponse();
Expand Down Expand Up @@ -168,6 +169,7 @@ public void testEncodeBrief() throws Exception {
dom); dom);
} }


@Test
public void testEncodeSummary() throws Exception { public void testEncodeSummary() throws Exception {
// setup the request // setup the request
CSWRecordsResult response = getCSWResponse(); CSWRecordsResult response = getCSWResponse();
Expand Down Expand Up @@ -218,6 +220,7 @@ public void testEncodeSummary() throws Exception {
dom); dom);
} }


@Test
public void testEncodeFull() throws Exception { public void testEncodeFull() throws Exception {
// setup the request // setup the request
CSWRecordsResult response = getCSWResponse(); CSWRecordsResult response = getCSWResponse();
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.geotools.feature.NameImpl; import org.geotools.feature.NameImpl;
import org.geotools.filter.SortByImpl; import org.geotools.filter.SortByImpl;
import org.geotools.util.factory.Hints; import org.geotools.util.factory.Hints;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.opengis.feature.Attribute; import org.opengis.feature.Attribute;
import org.opengis.feature.ComplexAttribute; import org.opengis.feature.ComplexAttribute;
Expand All @@ -54,7 +55,8 @@ public class SimpleCatalogStoreTest {
File root = new File("./src/test/resources/org/geoserver/csw/store/simple"); File root = new File("./src/test/resources/org/geoserver/csw/store/simple");
SimpleCatalogStore store = new SimpleCatalogStore(Files.asResource(root)); SimpleCatalogStore store = new SimpleCatalogStore(Files.asResource(root));


protected void setUp() throws Exception { @BeforeClass
public static void setUp() {
Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, true); Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, true);
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
Expand Down Expand Up @@ -462,7 +463,7 @@ Mosaic mosaic(JSONObject json) throws IOException {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"time object must specific mode property as " "time object must specific mode property as "
+ "one of " + "one of "
+ TimeMode.values()); + Arrays.asList(TimeMode.values()));
} }


m.setTimeMode(TimeMode.valueOf(time.getString("mode").toUpperCase())); m.setTimeMode(TimeMode.valueOf(time.getString("mode").toUpperCase()));
Expand All @@ -483,7 +484,7 @@ public Directory directory(JSONObject json) throws IOException {
} }
} }


Database database(JSONObject json) throws IOException { Database database(JSONObject json) {
throw new UnsupportedOperationException("TODO: implement"); throw new UnsupportedOperationException("TODO: implement");
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public Component buildComponent(String id) {
} }


@Test @Test
@SuppressWarnings("TryFailThrowable")
public void testNoInspireSettingsWMS() { public void testNoInspireSettingsWMS() {
final ServiceInfo serviceInfo = getGeoServer().getService(WMSInfo.class); final ServiceInfo serviceInfo = getGeoServer().getService(WMSInfo.class);
final MetadataMap metadata = serviceInfo.getMetadata(); final MetadataMap metadata = serviceInfo.getMetadata();
Expand Down Expand Up @@ -142,6 +143,7 @@ public void testCreateExtCapsOffWCS() {
} }


@Test @Test
@SuppressWarnings("TryFailThrowable")
public void testWithFullSettingsWMS() { public void testWithFullSettingsWMS() {
final ServiceInfo serviceInfo = getGeoServer().getService(WMSInfo.class); final ServiceInfo serviceInfo = getGeoServer().getService(WMSInfo.class);
final MetadataMap metadata = serviceInfo.getMetadata(); final MetadataMap metadata = serviceInfo.getMetadata();
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public void writer() throws IOException {
new ImageWorker(output).getBufferedImage().flush(); new ImageWorker(output).getBufferedImage().flush();
} }


@Test
public void testWriterBandSelect() throws IOException { public void testWriterBandSelect() throws IOException {
if (SKIP_TESTS) { if (SKIP_TESTS) {
LOGGER.warning(ERROR_LIB_MESSAGE); LOGGER.warning(ERROR_LIB_MESSAGE);
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -78,46 +78,9 @@ public void finished(Request request) {}
assertEquals(Status.RUNNING, data.getStatus()); assertEquals(Status.RUNNING, data.getStatus());
} }


@Test
public void testGetRunningAndBlockedRequests() throws Exception { public void testGetRunningAndBlockedRequests() throws Exception {
DispatcherCallback callback = DispatcherCallback callback = new MyDispatcherCallback();
new DispatcherCallback() {

public long getRunningRequests() {
return 10;
}

public long getBlockedRequests() {
return 2;
}

public Service serviceDispatched(Request request, Service service)
throws ServiceException {
return null;
}

public Response responseDispatched(
Request request,
Operation operation,
Object result,
Response response) {
return null;
}

public Object operationExecuted(
Request request, Operation operation, Object result) {
return null;
}

public Operation operationDispatched(Request request, Operation operation) {
return null;
}

public Request init(Request request) {
return null;
}

public void finished(Request request) {}
};
callback = createProxy(callback); callback = createProxy(callback);
ControlFlowCallbackProxy proxy = ControlFlowCallbackProxy proxy =
(ControlFlowCallbackProxy) Proxy.getInvocationHandler(callback); (ControlFlowCallbackProxy) Proxy.getInvocationHandler(callback);
Expand All @@ -132,4 +95,38 @@ DispatcherCallback createProxy(DispatcherCallback callback) {
Proxy.newProxyInstance( Proxy.newProxyInstance(
getClass().getClassLoader(), new Class[] {DispatcherCallback.class}, proxy); getClass().getClassLoader(), new Class[] {DispatcherCallback.class}, proxy);
} }

public static class MyDispatcherCallback implements DispatcherCallback {

public long getRunningRequests() {
return 10;
}

public long getBlockedRequests() {
return 2;
}

public Service serviceDispatched(Request request, Service service) throws ServiceException {
return null;
}

public Response responseDispatched(
Request request, Operation operation, Object result, Response response) {
return null;
}

public Object operationExecuted(Request request, Operation operation, Object result) {
return null;
}

public Operation operationDispatched(Request request, Operation operation) {
return null;
}

public Request init(Request request) {
return null;
}

public void finished(Request request) {}
}
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS; import org.geotools.referencing.CRS;
import org.geotools.util.Version; import org.geotools.util.Version;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
Expand Down Expand Up @@ -153,6 +154,7 @@ public void setUp() throws Exception {
data = monitor.start(); data = monitor.start();
} }


@After
public void tearDown() throws Exception { public void tearDown() throws Exception {
monitor.complete(); monitor.complete();
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.geoserver.test.GeoServerSystemTestSupport; import org.geoserver.test.GeoServerSystemTestSupport;
import org.geotools.filter.text.cql2.CQL; import org.geotools.filter.text.cql2.CQL;
import org.geotools.filter.text.cql2.CQLException; import org.geotools.filter.text.cql2.CQLException;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
Expand Down Expand Up @@ -107,6 +108,7 @@ public void setUp() throws Exception {
data = monitor.start(); data = monitor.start();
} }


@After
public void tearDown() throws Exception { public void tearDown() throws Exception {
monitor.complete(); monitor.complete();
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -84,8 +83,6 @@ public void testConfigurationLoad() throws Exception {
assertTrue(formatNames.contains("OGR-MIF")); assertTrue(formatNames.contains("OGR-MIF"));
assertTrue(formatNames.contains("OGR-CSV")); assertTrue(formatNames.contains("OGR-CSV"));
assertTrue(formatNames.contains("OGR-KML")); assertTrue(formatNames.contains("OGR-KML"));
} catch (IOException e) {
System.err.println(e.getStackTrace());
} finally { } finally {
if (configuration != null) { if (configuration != null) {
configuration.delete(); configuration.delete();
Expand Down Expand Up @@ -132,9 +129,6 @@ public void testOGRKMLOutputExecuteRaw() throws Exception {
getWpsRawXML("application/vnd.google-earth.kml; subtype=OGR-KML")); getWpsRawXML("application/vnd.google-earth.kml; subtype=OGR-KML"));
assertEquals("application/vnd.google-earth.kml; subtype=OGR-KML", r.getContentType()); assertEquals("application/vnd.google-earth.kml; subtype=OGR-KML", r.getContentType());
assertTrue(r.getContentAsString().length() > 0); assertTrue(r.getContentAsString().length() > 0);

} catch (IOException e) {
System.err.println(e.getStackTrace());
} finally { } finally {
if (configuration != null) { if (configuration != null) {
configuration.delete(); configuration.delete();
Expand All @@ -158,8 +152,6 @@ public void testOGRKMLOutputExecuteDocument() throws Exception {
d, d,
xml.hasOneNode( xml.hasOneNode(
"//kml:kml/kml:Document/kml:Schema | //kml:kml/kml:Document/kml:Folder/kml:Schema")); "//kml:kml/kml:Document/kml:Schema | //kml:kml/kml:Document/kml:Folder/kml:Schema"));
} catch (IOException e) {
System.err.println(e.getStackTrace());
} finally { } finally {
if (configuration != null) { if (configuration != null) {
configuration.delete(); configuration.delete();
Expand All @@ -182,8 +174,6 @@ public void testOGRCSVOutputExecuteDocument() throws Exception {
assertTrue( assertTrue(
r.getContentAsString().contains("WKT,gml_id,STATE_NAME") r.getContentAsString().contains("WKT,gml_id,STATE_NAME")
|| r.getContentAsString().contains("geometry,gml_id,STATE_NAME")); || r.getContentAsString().contains("geometry,gml_id,STATE_NAME"));
} catch (IOException e) {
System.err.println(e.getStackTrace());
} finally { } finally {
if (configuration != null) { if (configuration != null) {
configuration.delete(); configuration.delete();
Expand Down Expand Up @@ -216,8 +206,6 @@ public void testOGRBinaryOutputExecuteDocument() throws Exception {
} }
zis.close(); zis.close();
assertTrue(found); assertTrue(found);
} catch (IOException e) {
System.err.println(e.getStackTrace());
} finally { } finally {
if (configuration != null) { if (configuration != null) {
configuration.delete(); configuration.delete();
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import net.opengis.ows11.BoundingBoxType; import net.opengis.ows11.BoundingBoxType;
import net.opengis.ows11.Ows11Factory; import net.opengis.ows11.Ows11Factory;
import org.geoserver.wps.WPSException; import org.geoserver.wps.WPSException;
Expand Down Expand Up @@ -109,8 +110,8 @@ BoundingBoxType fromTargetType(Object object) throws WPSException {
} else if (org.opengis.geometry.Envelope.class.isAssignableFrom(getType())) { } else if (org.opengis.geometry.Envelope.class.isAssignableFrom(getType())) {
org.opengis.geometry.Envelope env = (org.opengis.geometry.Envelope) object; org.opengis.geometry.Envelope env = (org.opengis.geometry.Envelope) object;
crs = env.getCoordinateReferenceSystem(); crs = env.getCoordinateReferenceSystem();
bbox.setLowerCorner(Arrays.asList(env.getLowerCorner().getCoordinate())); bbox.setLowerCorner(doubleArrayToList(env.getLowerCorner().getCoordinate()));
bbox.setUpperCorner(Arrays.asList(env.getUpperCorner().getCoordinate())); bbox.setUpperCorner(doubleArrayToList(env.getUpperCorner().getCoordinate()));
} else { } else {
throw new WPSException( throw new WPSException(
"Failed to convert from " + object + " to an OWS 1.1 Bounding box type"); "Failed to convert from " + object + " to an OWS 1.1 Bounding box type");
Expand All @@ -130,4 +131,8 @@ BoundingBoxType fromTargetType(Object object) throws WPSException {


return bbox; return bbox;
} }

private List<Double> doubleArrayToList(double[] coordinate) {
return Arrays.stream(coordinate).boxed().collect(Collectors.toList());
}
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ private void waitTileBreederCompletion() throws InterruptedException {
if (now - start > MAX_WAIT_SECS * 1000) { if (now - start > MAX_WAIT_SECS * 1000) {
String message = String message =
format( format(
"Waited for tile breeder to finish its tasks for more than % seconds", "Waited for tile breeder to finish its tasks for more than %d seconds",
MAX_WAIT_SECS); MAX_WAIT_SECS);
fail(message); fail(message);
} }
Expand Down
1 change: 1 addition & 0 deletions src/gwc/src/test/java/org/geoserver/gwc/GWCTest.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ private void mockTileLayerDispatcher() throws Exception {
when(tld.layerExists(eq(tileLayerGroup.getName()))).thenReturn(true); when(tld.layerExists(eq(tileLayerGroup.getName()))).thenReturn(true);
} }


@Test
public void testAddTileLayer() throws Exception { public void testAddTileLayer() throws Exception {


doThrow(new IllegalArgumentException("fake")).when(tld).addLayer(same(tileLayer)); doThrow(new IllegalArgumentException("fake")).when(tld).addLayer(same(tileLayer));
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.geoserver.kml.utils; package org.geoserver.kml.utils;


import de.micromata.opengis.kml.v_2_2_0.AltitudeMode; import de.micromata.opengis.kml.v_2_2_0.AltitudeMode;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
Expand Down Expand Up @@ -165,7 +166,7 @@ private AltitudeMode parseAltitudeMode(final Object object) {
"Illegal value for KML format option 'altitudeMode': '" "Illegal value for KML format option 'altitudeMode': '"
+ object + object
+ "'. Expected one of " + "'. Expected one of "
+ AltitudeMode.values()); + Arrays.toString(AltitudeMode.values()));
} }
} }
} }
Expand Down
16 changes: 0 additions & 16 deletions src/main/src/main/java/org/geoserver/catalog/util/ReaderUtils.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -416,22 +416,6 @@ public static String getChildAttribute(
return elem.getAttribute(attName); return elem.getAttribute(attName);
} }


public static boolean getChildAttributeAsBoolean(
Element root, String childName, String attName) {
String value = getChildAttribute(root, childName, attName);
return value != null ? Boolean.parseBoolean(value) : null;
}

public static int getChildAttributeAsInt(Element root, String childName, String attName) {
String value = getChildAttribute(root, childName, attName);
return value != null ? Integer.parseInt(value) : null;
}

public static double getChildAttributeAsDouble(Element root, String childName, String attName) {
String value = getChildAttribute(root, childName, attName);
return value != null ? Double.parseDouble(value) : null;
}

/** /**
* getChildText purpose. * getChildText purpose.
* *
Expand Down

0 comments on commit 1de976d

Please sign in to comment.