Emerson Wang created an issue |
JMSCatalogListener Unable Find Style for Event for Rest API Creating a Style |
Issue Type: |
Bug |
---|---|
Affects Versions: |
2.18.0 |
Assignee: |
Unassigned |
Attachments: |
geoserverlog.rtf |
Components: |
Community modules |
Created: |
28/Oct/20 5:52 PM |
Environment: |
5 nodes installed geoserver 2.18 with 2.18 active clustering extension |
Priority: |
Medium |
Reporter: |
The new styles created through GeoServer UI were published to the other cluster nodes but failed to publish the new styles created by REST API to the cluster nodes. Attached please find the GeoServer log.
Following RESR API https://docs.geoserver.org/stable/en/user/rest/styles.html
curl -k -v -u admin:*** -XPOST -H “Content-type: text/xml” -d “<style><name>test_debug2</name><filename>geomatic_th_test_sidm_0.sld</filename></style>” https:/geoservers/geoserver/rest/styles
curl -v -u admin:*** -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @test.sld https://geoservers/geoserver/rest/styles/geomatic_th_test_sidm_0
JMSCatalogListener.java failed in the check, i.e., !Resources.exists(styleFile), (source code - https://github.com/geoserver/geoserver/blob/master/src/community/jms-cluster/jms-geoserver/src/main/java/org/geoserver/cluster/server/JMSCatalogListener.java):
// checks
if (!Resources.exists(styleFile)
!Resources.canRead(styleFile) |
---|
!(styleFile.getType() == Type.RESOURCE)) { throw new IllegalStateException( "Unable to find style for event: " + sInfo.toString()); } |
Inside Resources.exists(), styleFile.getTypes() returned Resource.Type.UNDEFINED and thus Resources.exists() return false. We simply moved the first check !Resources.exists(styleFile) after the second check !Resources.canRead(styleFile) as follows:
// checks
if (!Resources.canRead(styleFile)
!Resources.exists(styleFile) |
---|
!(styleFile.getType() == Type.RESOURCE)) { throw new IllegalStateException( "Unable to find style for event: " + sInfo.toString()); } |
styleFile.getType() returned Type.RESOURCE, exists() returned true, and thus resolved the error. It seems that in the first check, i.e., !Resources.exists(styleFile), styleFile was just initialized but not populated with values for REST API created styles. After the second check, i.e., Resource.in() & Resource.read(), styleFile was populated with the correct values and thus exists() worked as expected.
Suggest to switch the places between the first check exists() and the second check canRead() in the original code or removing the first check, and the second check canRead() can cover the first check, if canRead() returns true. exists() must return true. If canRead() returns false, exists() check doesn’t matter.
Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS |
|
This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100149-sha1:381bf55) |