diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/Serialisers.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/Serialisers.java index 18cbc955d960fe..2280983015cdb9 100644 --- a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/Serialisers.java +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/Serialisers.java @@ -164,7 +164,7 @@ protected List findResourceWriters(QuarkusMultivaluedMap ret = new ArrayList<>(); Deque> toProcess = new LinkedList<>(); do { - if (currentClass == Object.class) { + if (currentClass == Object.class && !toProcess.isEmpty()) { //spec extension, look for interfaces as well //we match interfaces before Object Set> seen = new HashSet<>(toProcess); @@ -182,13 +182,16 @@ protected List findResourceWriters(QuarkusMultivaluedMap goodTypeWriters = writers.get(currentClass); writerLookup(runtimeType, produces, desired, ret, goodTypeWriters); - toProcess.addAll(Arrays.asList(currentClass.getInterfaces())); + var prevClass = currentClass; // if we're an interface, pretend our superclass is Object to get us through the same logic as a class if (currentClass.isInterface()) { currentClass = Object.class; } else { currentClass = currentClass.getSuperclass(); } + if (currentClass != null) { + toProcess.addAll(List.of(prevClass.getInterfaces())); + } } while (currentClass != null); return ret;