Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
Setting limit throws IllegalFormatConversionException
Browse files Browse the repository at this point in the history
At the moment, setting the limit parameter throws the following exception:
```
java.util.IllegalFormatConversionException: d != java.lang.String
	at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4045)
	at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2748)
	at java.util.Formatter$FormatSpecifier.print(Formatter.java:2702)
	at java.util.Formatter.format(Formatter.java:2488)
	at java.util.Formatter.format(Formatter.java:2423)
	at java.lang.String.format(String.java:2834)
	at fr.dudie.nominatim.client.request.QueryParameterAnnotationHandler.process(QueryParameterAnnotationHandler.java:97)
	at fr.dudie.nominatim.client.request.NominatimRequest.getQueryString(NominatimRequest.java:47)
	at fr.dudie.nominatim.client.JsonNominatimClient.search(JsonNominatimClient.java:188)
```
The issue is that the following line of code ```String paramValue = serialize(paramMetadata, fieldValue, f.getName());``` in ```QueryParameterAnnotationHandler.process(final Object o) (line 88)``` method converts the value of limit parameter from Integer to String. 

However when you try to format the value as it is done in ```String.format(Locale.US, paramFormat, paramValue)``` in ```QueryParameterAnnotationHandler.process(final Object o) (line 97)```, it uses the %d formatter for limit specified in ```QueryParmeter```. For instance if you set the limit to 3, the following code is executed ```String.format(Locale.US, "%d", "3")``` which results in the above exception.
  • Loading branch information
jugalps committed Jan 16, 2015
1 parent d86fa32 commit 29d1e14
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class NominatimSearchRequest extends NominatimRequest {
private List<String> excludePlaceIds;

/** Limit the number of returned results. */
@QueryParameter("limit=%d")
@QueryParameter("limit=%s")
private Integer limit;

/** Choose output geometry format. */
Expand Down Expand Up @@ -345,4 +345,4 @@ public PolygonFormat getPolygonFormat() {
public void setPolygonFormat(PolygonFormat polygonFormat) {
this.polygonFormat = polygonFormat;
}
}
}

0 comments on commit 29d1e14

Please sign in to comment.