Skip to content

Commit

Permalink
ClassCastException during Graal native image and ReST Client (helidon…
Browse files Browse the repository at this point in the history
…-io#2917)

* Addresses helidon-io#2913
* Adding primitive PathParam
  • Loading branch information
dansiviter authored and aseovic committed Apr 26, 2021
1 parent 2a5a09e commit 6c7cce8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,17 @@ private Class<?> getSimpleType(BeforeAnalysisContext context,
TypeSignature typeDescriptor = typeDescriptorSupplier.get();
return getSimpleType(context, typeDescriptor);
}
ClassRefTypeSignature refType = (ClassRefTypeSignature) typeSignature;
List<TypeArgument> typeArguments = refType.getTypeArguments();
if (typeArguments.size() != 1) {
return getSimpleType(context, typeSignature);
}

TypeArgument typeArgument = typeArguments.get(0);
ReferenceTypeSignature ref = typeArgument.getTypeSignature();
if (ref == null) {
return Object.class;
if (typeSignature instanceof ClassRefTypeSignature) {
ClassRefTypeSignature refType = (ClassRefTypeSignature) typeSignature;
List<TypeArgument> typeArguments = refType.getTypeArguments();
if (typeArguments.size() == 1) {
TypeArgument typeArgument = typeArguments.get(0);
ReferenceTypeSignature ref = typeArgument.getTypeSignature();
return getSimpleType(context, ref);
}
}
return getSimpleType(context, ref);
return getSimpleType(context, typeSignature);
}

private Class<?> getSimpleType(BeforeAnalysisContext context, TypeSignature typeSignature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,10 @@ public String queryParam(@QueryParam("long") Long longParam) {
public String queryParam(@QueryParam("boolean") Boolean booleanParam) {
return String.valueOf(booleanParam);
}

@GET
@Path("/queryparam3")
public String queryParam(@QueryParam("int") int intParam) {
return String.valueOf(intParam);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ private static void testBean(int port, String jwtToken) {
// + JSON-B
invoke(collector, "Rest client JSON-B", "json-b", aBean::restClientJsonB);
// + query params
invoke(collector, "Rest client Query param long", "1020", () -> aBean.restClientQuery(1020L));
invoke(collector, "Rest client Query param boolean", "true", () -> aBean.restClientQuery(true));
invoke(collector, "Rest client Query param Long", "1020", () -> aBean.restClientQuery(1020L));
invoke(collector, "Rest client Query param Boolean", "true", () -> aBean.restClientQuery(true));
invoke(collector, "Rest client Query param int", "123", () -> aBean.restClientQuery(123));

// Message from rest client, originating in BeanClass.BeanType
invoke(collector, "Rest client bean type", "Properties message", aBean::restClientBeanType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,4 +54,8 @@ public interface RestClientIface {
@GET
@Path("/queryparam2")
String queryParam(@QueryParam("boolean") Boolean booleanParam);

@GET
@Path("/queryparam3")
String queryParam(@QueryParam("int") int intParam);
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ public String restClientQuery(Boolean param) {
.queryParam(param);
}

public String restClientQuery(int param) {
return restClient()
.queryParam(param);
}

@Fallback(fallbackMethod = "fallbackTo")
public String fallback() {
throw new RuntimeException("intentional failure");
Expand Down

0 comments on commit 6c7cce8

Please sign in to comment.