Skip to content

Conversation

@dirk-jamieson-aem
Copy link
Contributor

Problem

SRS comparison bug is leading to missing bounding box in WMTS capabilities in GeoServer.

Replication

I've created a Gridset using the GeoServer GWC REST API and assigned it to my layer in GeoServer. Now I view my layer capabilities, and there's no WGS84BoundingBox associated with the layer. Assigning a standard WebMercatorGrid resolves the issue, but I don't want that gridset.

Why it happens

This seems to happen because TileLayer#getGridSubsetForSRS(..) can't locate a gridset that's using EPSG:900913 or EPSG:4326 on my layer. Except I have my gridset defined as EPSG:3857, which is an alias of EPSG:900913. A bug in the comparison code seems to be preventing it from accepting EPSG:3857 as an alias!

Normally, this is fine because SRS is accessed using the static method SRS.getSRS(..) which looks it up in a cache. Unfortunately, during XML deserialization, I believe the private constructor is being invoked. That leaves aliases as null, which broke the comparison logic.

Alternative fixes might include initializing the aliases to an empty list, or adding a SRS-specific deserializer.

Constructor<SRS> constructor = SRS.class.getDeclaredConstructor(int.class, List.class);
constructor.setAccessible(true);

return constructor.newInstance(epsgCode, aliases);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using reflection here, because it simulates what the XML deserialization process is doing - invoking the private constructor without initializing the aliases list.

SRS srs2 = createSRSWithReflection(3857);

Assert.assertEquals("Expect two alias SRS to be equal", srs1, srs2);
Assert.assertEquals("Expect two alias SRS to be equal", srs2, srs1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the case that is failing in the current release

@aaime aaime merged commit e456e44 into GeoWebCache:main Nov 24, 2025
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants