Skip to content

Commit 39ffd8e

Browse files
committed
fix #390 - reverse the algorithm for matching against registered classes
(cherry picked from commit 1ae5bd9)
1 parent 9bb0adb commit 39ffd8e

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/main/java/com/marklogic/client/impl/HandleFactoryRegistryImpl.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,14 @@ public HandleFactoryRegistry copy() {
126126
return copy;
127127
}
128128
Class<?> getRegisteredType(Class<?> type) {
129-
while (type != null && !type.isAssignableFrom(Object.class)) {
130-
if (factories.containsKey(type)) {
131-
return type;
132-
}
133-
134-
Class<?>[] interfaces = type.getInterfaces();
135-
if (interfaces != null) {
136-
for (Class<?> interfaceType: interfaces) {
137-
if (factories.containsKey(interfaceType)) {
138-
return interfaceType;
139-
}
140-
}
129+
if ( type == null ) throw new IllegalArgumentException("type must not be null");
130+
if (factories.containsKey(type)) {
131+
return type;
132+
}
133+
for ( Class<?> registeredClass : factories.keySet() ) {
134+
if ( registeredClass.isAssignableFrom(type) ) {
135+
return registeredClass;
141136
}
142-
143-
type = type.getSuperclass();
144137
}
145138

146139
return null;

0 commit comments

Comments
 (0)