Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.2.4
-
None
-
Operating System: All
Platform: All
-
34314
Description
The TilesRequestProcessor currently calls the
DefinitionsFactory "getDefinition" method. In the API docs this interface is
declared to throw 2 exceptions (DefinitionsFactoryException and
NoSuchDefinitionException). Currently the TilesRequestProcessor ONLY catches
DefinitionsFactoryException in the "processTilesDefinition" method. This
becomes a problem because since NoSuchDefinitionException extends
DefinitionsFactoryException. Therefore they essentially get lumped into the
same action and throw a ServletException.
This is not desireable because in the case where I implented my own
DefinitionsFactory I follow the specification and throw a
NoSuchDefinitionException when I do not find the corresponding definition
matching the given definition name. An example that fails is when the tiles
request processor calls the "getDefinition" with a path to a jsp page rather
than a tile name. My tiles definition factory throws a
NoSuchDefinitionException as it should according to the spec. At this point
the "processTilesDefinition" should return false but instead throws a
ServletException.
Solutions: A distinction needs to be made between the two exceptions being
thrown. Therefore I recommend a catch block for the NoSuchDefinitionException
be placed before the catch block for the
DefinitionsFactoryException in the "processTilesDefinition" method. In the
NoSuchDefinitionException catch block a "return false" statement should be
executed to hint that the definition was simply not found, rather than an error
in retrieving the definitions.
As of now - you simply check to see if the returned TileDefinition is null, if
not null you return true that the tile was found, otherwise if null false is
returned. The specification says nothing about returning null from a
DefinitionsFactory if a tile is not found.