We are using a model with name Process in graphql api. while building the manifest, we are getting ambiguity error like below.
QueryResolver.java:[12,20] reference to Process is ambiguous from both classes com..Process and java.lang.Process.*
How can I explicitly mention the QueryResolver to use the java.lang.Process in the below methods ?
'''
#javax.validation.constraints.NotNull
java.util.List Process(ProcessInput input,graphql.schema.DataFetchingEnvironment env) throws Exception;
'''
The following customTypeMapping tag solved my issue, We need to specify what type compiler need to use in runtime.
<customTypesMapping>
<Process>com..schema.model.Process</Process>
</customTypesMapping>
You can find more details here
https://github.com/kobylynskyi/graphql-java-codegen/tree/master/plugins/maven
Related
I've got an integration flow written in the Java DSL
I'm enriching the header of a message to include an AtomicInteger:
.enrichHeaders(t -> t.headerFunction(pollTime,message -> new AtomicInteger()))
If I put a breakpoint on the subsequent handle method in the same flow I can see the header and it's a String not an AtomicInteger.
So if I try to retrieve it in another flow like so I get an illegal argument exception:
message.getHeaders().get(pollTime,AtomicInteger.class).getAndAdd(delay);
Caused by: java.lang.IllegalArgumentException: Incorrect type specified for header 'pollTime'. Expected [class java.util.concurrent.atomic.AtomicInteger] but actual type is [class java.lang.String]
If I do the same thing in the Kotlin DSL it all works fine:
enrichHeaders {
headerFunction<Any>(pollCount) {
AtomicInteger()
}
}
Does anyone have any idea of what I am doing wrong ?
I created a stand alone project to reproduce the error, and that added in the header as an expected AtomicInteger.
Then I debugged our main application and it turns out there's an OpenTracingChannelInterceptor which is re-writing all headers as Strings.
This library is the culprit:
io.opentracing.contrib:opentracing-spring-messaging:0.0.5 which is transitive dependency of io.opentracing.contrib:opentracing-spring-cloud-starter-jaeger
It looks like adding this library just breaks Spring Integration.
The fix is to exclude the tracing autoconfiguration:
#SpringBootApplication(exclude = {OpenTracingChannelInterceptorAutoConfiguration.class})
Update:
The opentracing library is now longer maintained so the long term fix for this would be to migrate to a different tracing library that hopefully doesn't have the same type of issue.
See
https://www.cncf.io/blog/2022/01/31/cncf-archives-the-opentracing-project/
In my company, we're starting to mix Kotlin with Java and found a curious scenario. When I place a Java annotation on a property parameter of a constructor in a Kotlin class, and use a non-existent reference as one of the annotation's parameters, IntelliJ visually indicates an error, but both its build (Ctrl+F9) and maven's build compile normally, without errors.
We're using Java 8 and Kotlin 1.4.20.
Here's the annotation, declared as a Java file:
#Retention(RetentionPolicy.RUNTIME)
#Target({ElementType.FIELD, ElementType.METHOD})
public #interface Required {
String scope() default "ABC";
}
And here's the Kotlin class using the annotation (class Abc does not exist):
data class Test(
// Compiles normally
#Required(scope = Abc.X)
val text: String
) {
// Compilation error
#Required(scope = Abc.X)
fun x() {
}
}
As mentioned in the code comments, the same annotation placed in a Kotlin function behaves as expected (that is, the code does not compile). An equivalent annotation declared as a Kotlin file also behaves as expected.
When the code is run, the scope variable assumes its default value, so there are no runtime errors.
I've already tried to:
Invalidate IntelliJ cache and restart.
Switch the annotation declaration from #Required(scope = Abc.X) to #field:Required(scope = Abc.X)
I also tried to replicate the behaviour in a brand new project without inheriting from the company's base maven project, but to no avail.
Honestly, I think there's a huge possibility that it is something related to the company's project. I know I haven't specified what my company uses and all the configuration (in fact, the question would get way too big if I did that), but I hope that even with just the basic problem someone may be able to help.
This is a Kotlin compiler bug: argument list is not analyzed for usage of Java annotation with #Target(FIELD) on Kotlin property.
For updates on this please follow the issue https://youtrack.jetbrains.com/issue/KT-33822.
I want to verity two dates parameters in a class, start day must before end day. However, I have multiple classes which have this demand, so I want to customize a generic annotation.
what I have tried:
class dataValidator<T : Any>: ConstraintValidator<DateConstraint, T>
It raised a error:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'my.test.annotation.DateValid' validating type 'my.test.model.DateModel'. Check configuration for ''
However, if I change my validator to this, and it works
class dataValidator<T : Any>: ConstraintValidator<DateConstraint, DateModel>
So, is there any way I can write a generic annotation?
Normally this problem will happen when you are trying to use incorrect validator annotation on any bean property, you must use the right annotations for the right types.
You can find more information here
I have a compile problem which is strange. I am not able to fix this. The same peice of code works fine in another project
org.mockito.Mockito.when(jdbcTemplate.query(org.mockito.Matchers.anyString(),
org.mockito.Matchers.any(BeanPropertyRowMapper.class))).thenReturn(SOMELIST);
I am getting error as
The method query(String, ResultSetExtractor<T>) in the type JdbcTemplate is not applicable for the arguments (String, BeanPropertyRowMapper)
But When I do this, I do not get any error. But I am not expecting this.
BeanPropertyRowMapper<MyClass> mapper =
new BeanPropertyRowMapper<MyClass>(MyClass.class);
org.mockito.Mockito.when(jdbcTemplate.query(org.mockito.Matchers.anyString(),
mapper)).thenReturn(SOMELIST);
I am not sure if this is an Eclipse problem. Appreciate your help on this.
Since BeanPropertyRowMapper<T> is a generic interface, you should invoke any() like this:
Mockito.when(jdbcTemplate.query(Matchers.anyString(),
Matchers.<BeanPropertyRowMapper<MyClass>>any())).thenReturn(SOMELIST);
Check for the dependency (spring jars) for version mismatch between projects
This is regarding Spring property editors.
I have a Interface A that is being implemented to Class B and C.
I have a command class Doc in which in which i have a list of A
class Doc{
List<A> list ;
}
list may contain either object of B or C. In this situation how could i use property editor. i wrote two property editor for the two classes and register them in initBinder method as
binder.registerCustomEditor(C.class,new CPropertyEditor());
binder.registerCustomEditor(B.class,new BPropertyEditor());
but it does not seems to be working. Please help.
i am getting the following exception:
Request processing failed; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.test.A] for property list: no matching editors or conversion strategy found
This is my first post so please sorry if i made any mistake.
One approach is to implement a single property editor for A. The implementation can look at the string and then create an instance of B or C.