[Geoserver-devel] [JIRA] (GEOS-7517) HTTP 500 response doing a REST PUT to non-existent style (404 expected)

Torben Barsballe created an issue

GeoServer / BugGEOS-7517

HTTP 500 response doing a REST PUT to non-existent style (404 expected)

Issue Type:

BugBug

Affects Versions:

2.9-beta2

Assignee:

Unassigned

Components:

REST

Created:

22/Apr/16 1:57 AM

Priority:

MediumMedium

Reporter:

Torben Barsballe

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.

Add Comment

Add Comment

This message was sent by Atlassian JIRA (v7.2.0-OD-05-030#72002-sha1:7e8526a)

Atlassian logo