Emerson Wang ( 
https://osgeo-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A49a74864-bf4c-4fb7-a176-97b01dcf884f
 ) *created* an issue

GeoServer ( 
https://osgeo-org.atlassian.net/browse/GEOS?atlOrigin=eyJpIjoiYTg1NmE5ZGU4NDFkNDlkZThjN2FmMjBiNmZiNDJhOTUiLCJwIjoiaiJ9
 ) / Bug ( 
https://osgeo-org.atlassian.net/browse/GEOS-9782?atlOrigin=eyJpIjoiYTg1NmE5ZGU4NDFkNDlkZThjN2FmMjBiNmZiNDJhOTUiLCJwIjoiaiJ9
 ) GEOS-9782 ( 
https://osgeo-org.atlassian.net/browse/GEOS-9782?atlOrigin=eyJpIjoiYTg1NmE5ZGU4NDFkNDlkZThjN2FmMjBiNmZiNDJhOTUiLCJwIjoiaiJ9
 ) JMSCatalogListener Unable Find Style for Event for Rest API Creating a Style 
( 
https://osgeo-org.atlassian.net/browse/GEOS-9782?atlOrigin=eyJpIjoiYTg1NmE5ZGU4NDFkNDlkZThjN2FmMjBiNmZiNDJhOTUiLCJwIjoiaiJ9
 )

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: Emerson Wang ( 
https://osgeo-org.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A49a74864-bf4c-4fb7-a176-97b01dcf884f
 )

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.

( 
https://osgeo-org.atlassian.net/browse/GEOS-9782#add-comment?atlOrigin=eyJpIjoiYTg1NmE5ZGU4NDFkNDlkZThjN2FmMjBiNmZiNDJhOTUiLCJwIjoiaiJ9
 ) Add Comment ( 
https://osgeo-org.atlassian.net/browse/GEOS-9782#add-comment?atlOrigin=eyJpIjoiYTg1NmE5ZGU4NDFkNDlkZThjN2FmMjBiNmZiNDJhOTUiLCJwIjoiaiJ9
 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( 
https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail
 ) or iOS ( 
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8
 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100149- 
sha1:381bf55 )
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to