cerner / beadledom

A simple, composable framework for building RESTful services

Home Page:http://engineering.cerner.com/beadledom

Repository from Github https://github.comcerner/beadledomRepository from Github https://github.comcerner/beadledom

Handle 0 value to LimitParameter gracefully by throwing BadRequest

venki09 opened this issue · comments

  • Device: Macbook pro 2017
  • OS version: 10.12.6 (High sierra)
  • Java SDK version: 1.8
  • Beadledom version: 3.1

Step 3: Describe the problem:

  • When a service call is made with limit parameter as 0, it is expected to return a BAD_REQUEST response. Instead INTERNAL_SERVER_ERROR is being returned.

Observed Results:

java.lang.ArithmeticException: / by zero
	at com.cerner.beadledom.pagination.OffsetPaginationLinks.lastLink(OffsetPaginationLinks.java:86) ~[beadledom-pagination-3.1.jar:na]
at com.cerner.beadledom.pagination.OffsetPaginatedListLinksWriterInterceptor.aroundWriteTo(OffsetPaginatedListLinksWriterInterceptor.java:39) ~[beadledom-pagination-3.1.jar:na]
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:129) ~[resteasy-jaxrs-3.6.1.Final.jar:3.6.1.Final]
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:92) ~[resteasy-jaxrs-3.6.1.Final.jar:3.6.1.Final]
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:129) ~[resteasy-jaxrs-3.6.1.Final.jar:3.6.1.Final]
at org.jboss.resteasy.plugins.interceptors.encoding.ServerContentEncodingAnnotationFilter.aroundWriteTo(ServerContentEncodingAnnotationFilter.java:60) ~[resteasy-jaxrs-3.6.1.Final.jar:3.6.1.Final]

Expected Results:

  • Return a BAD_REQUEST response.

Fixed by #118