Instead of the expected 404, you get a 500 responce and a null pointer exception in geoserver:
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.
Assumptions:
GeoServer is running on localhost:8080
Have a style
bar
in workspacefoo
foo
is the default workspaceSteps to reproduce:
Do a PUT against http://localhost:8080/geoserver/rest/styles/bar.xml
Instead of the expected 404, you get a 500 responce and a null pointer exception in geoserver:
The root cause of this issue is in
org.geoserver.catalog.rest.StyleFinder:54
, which does agetStyleByName(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 (which is an understandable mistake to make). In this instance,
foo
does not have to be the default workspace.