Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 3462fe6

Browse files
committed
#3587: Getting @priority annotation from proxied instance fails.
The fix work only on Weld 2.3+ and we can't update the dependency yet (we need to stay in sync with Glassfish), so there is no verifier, since Weld 2.2- doesn't mark proxies as synthetic. Change-Id: I2c1bec14a42e1809c6d2f525ab76ed509e9d3090
1 parent 0095db5 commit 3462fe6

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

core-common/src/main/java/org/glassfish/jersey/model/internal/RankedProvider.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -41,8 +41,8 @@
4141
package org.glassfish.jersey.model.internal;
4242

4343
import java.lang.reflect.Type;
44-
import java.util.Collections;
4544
import java.util.Set;
45+
4646
import javax.ws.rs.Priorities;
4747

4848
import javax.annotation.Priority;
@@ -100,8 +100,16 @@ private int computeRank(final T provider, final int rank) {
100100
if (rank > 0) {
101101
return rank;
102102
} else {
103-
if (provider.getClass().isAnnotationPresent(Priority.class)) {
104-
return provider.getClass().getAnnotation(Priority.class).value();
103+
Class<?> clazz = provider.getClass();
104+
105+
// when provided instance is a proxy (from weld), we need to get the right class to check for
106+
// @Priority annotation - proxy doesn't propagate isAnnotationPresent to the parent class.
107+
while (clazz.isSynthetic()) {
108+
clazz = clazz.getSuperclass();
109+
}
110+
111+
if (clazz.isAnnotationPresent(Priority.class)) {
112+
return clazz.getAnnotation(Priority.class).value();
105113
} else {
106114
return Priorities.USER;
107115
}

0 commit comments

Comments
 (0)