dependabot[bot] on gradle
xvik on master
Bump com.gradle.enterprise from… Merge pull request #241 from xv… (compare)
dependabot[bot] on gradle
xvik on master
Bump io.spring.dependency-manag… Merge pull request #242 from xv… (compare)
dependabot[bot] on gradle
Bump io.spring.dependency-manag… (compare)
dependabot[bot] on gradle
Bump com.gradle.enterprise from… (compare)
dependabot[bot] on gradle
Bump spock-core from 2.2-M1-gro… (compare)
dependabot[bot] on gradle
xvik on master
Bump com.gradle.enterprise from… Merge pull request #237 from xv… (compare)
hooks is a generic mechanism:
GuiceyConfigurationHook hook = builder -> builder.extensions(...);
here lambda used instead of direct inteface implementation
hook.register()
Dynamic features
CredentialRequiredFeature (c.k.restful.filter)
LoginRequiredFeature (c.k.restful.filter)
Exception mappers
IndexNotFoundException IndexNotFoundExceptionMapper (c.k.r.exceptionmapper)
ERROR [2020-06-16 18:22:29,915] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: c6536299f686a565
! org.apache.lucene.index.IndexNotFoundException: index 7617868c-fb63-41b5-81e6-50290cdc903exx does not exist
! at com.kalasearch.restful.filter.CredentialRequiredFilter.filter(CredentialRequiredFilter.java:61)
! at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:108)
bootstrap.addBundle(GuiceBundle.builder()
.extensions(IndexNotFoundExceptionMapper.class)
.extensions(
AccountResource.class,
AppResource.class,
IndexResource.class,
DocResource.class,
CredentialRequiredFeature.class,
LoginRequiredFeature.class
)
LoggingExceptionMapper
(shown in error log) is the default dropwizard mapper, so mappers mechanism was used. It is better to debug exception handling to see why it choose default handler instead of your custom mapper. org.glassfish.jersey.internal.ExceptionMapperFactory#find(java.lang.Class<T>, T)
- mapper selection logic
public Index getIndex(@PathParam("indexId") String indexId) {
Optional<Index> indexOpt = indexDao.findById(indexId);
if (indexOpt.isPresent()) {
return indexOpt.get();
} else {
throw new IndexNotFoundException(indexId);
}
}
@Provider
public class IndexNotFoundExceptionMapper
implements ExceptionMapper<IndexNotFoundException> {
@Override
public Response toResponse(IndexNotFoundException indexNotFoundException) {
int errorCode = ErrorConstants.INDEX_NOT_FOUND_CODE;
String errorMessage =
String.format(
ErrorConstants.INDEX_NOT_FOUND,
indexNotFoundException.getIndexId()
);
return Response
.status(Response.Status.NOT_FOUND)
.entity(
new KalaErrorEntity(
errorMessage,
errorCode
)
)
.build();
}
}