Assumptions:
- GeoServer is running on localhost:8080
- Have a style
bar in workspace foo
foo is the default workspace
Steps to reproduce:
Instead of the expected 404, you get a 500 responce and a null pointer exception in geoserver:
...
Caused by: java.lang.NullPointerException
at org.geoserver.config.GeoServerDataDirectory.style(GeoServerDataDirectory.java:1152)
at org.geoserver.catalog.ResourcePool.writeStyle(ResourcePool.java:1823)
at org.geoserver.catalog.rest.StyleResource.handleObjectPut(StyleResource.java:351)
at org.geoserver.rest.ReflectiveResource.handlePut(ReflectiveResource.java:194)
... 102 more
The root cause of this issue is in org.geoserver.catalog.rest.StyleFinder:54 , which does a getStyleByName(name) to test if the style exists globaly. Since getStyleByName checks the default workspace, it returns the workspaced style, despite no workspace being provided.
When StyleResouce later tries to get the StyleInfo object, it uses catalog.getStyleByName( workspace, style ) , with a null workspace, which returns null.
The same error occurs if you PUT to [http://localhost:8080/geoserver/rest/styles/foo:bar.xml](http://localhost:8080/geoserver/rest/styles/foo:bar.xml) (which is an understandable mistake to make). In this instance, foo does not have to be the default workspace.
|