|
1 | 1 | package org.jboss.resteasy.client.jaxrs.internal.proxy.processors; |
2 | 2 |
|
3 | | -import java.io.ByteArrayOutputStream; |
4 | | -import java.io.DataOutputStream; |
5 | 3 | import java.lang.annotation.Annotation; |
6 | 4 | import java.lang.reflect.Field; |
7 | 5 | import java.lang.reflect.InvocationTargetException; |
8 | 6 | import java.lang.reflect.Method; |
9 | 7 | import java.lang.reflect.Modifier; |
10 | 8 | import java.lang.reflect.Type; |
11 | | -import java.security.DigestOutputStream; |
12 | | -import java.security.MessageDigest; |
13 | 9 | import java.util.ArrayList; |
14 | 10 | import java.util.HashMap; |
15 | 11 | import java.util.List; |
|
20 | 16 | import org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration; |
21 | 17 | import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; |
22 | 18 | import org.jboss.resteasy.spi.LoggableFailure; |
| 19 | +import org.jboss.resteasy.spi.util.MethodHashing; |
23 | 20 |
|
24 | 21 | /** |
25 | 22 | * @author <a href="mailto:[email protected]">Bill Burke</a> |
@@ -48,32 +45,25 @@ public FormProcessor(final Class clazz, final ClientConfiguration configuration, |
48 | 45 | populateMap(clazz, configuration, defaultFormName); |
49 | 46 | } |
50 | 47 |
|
| 48 | + /** |
| 49 | + * @deprecated use {@link MethodHashing#methodHash(Method)} |
| 50 | + */ |
| 51 | + @Deprecated(forRemoval = true, since = "6.2.12.Final") |
51 | 52 | public static long methodHash(Method method) |
52 | 53 | throws Exception { |
53 | | - Class[] parameterTypes = method.getParameterTypes(); |
54 | | - StringBuilder methodDesc = new StringBuilder(method.getName()).append("("); |
55 | | - for (int j = 0; j < parameterTypes.length; j++) { |
56 | | - methodDesc.append(getTypeString(parameterTypes[j])); |
57 | | - } |
58 | | - methodDesc.append(")").append(getTypeString(method.getReturnType())); |
59 | | - return createHash(methodDesc.toString()); |
| 54 | + return MethodHashing.methodHash(method); |
60 | 55 | } |
61 | 56 |
|
| 57 | + /** |
| 58 | + * @deprecated use {@link MethodHashing#createHash(String)} |
| 59 | + */ |
| 60 | + @Deprecated(forRemoval = true, since = "6.2.12.Final") |
62 | 61 | public static long createHash(String methodDesc) |
63 | 62 | throws Exception { |
64 | | - long hash = 0; |
65 | | - ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512); |
66 | | - MessageDigest messagedigest = MessageDigest.getInstance("SHA"); |
67 | | - DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(bytearrayoutputstream, messagedigest)); |
68 | | - dataoutputstream.writeUTF(methodDesc); |
69 | | - dataoutputstream.flush(); |
70 | | - byte[] abyte0 = messagedigest.digest(); |
71 | | - for (int j = 0; j < Math.min(8, abyte0.length); j++) |
72 | | - hash += (long) (abyte0[j] & 0xff) << j * 8; |
73 | | - return hash; |
74 | | - |
| 63 | + return MethodHashing.createHash(methodDesc); |
75 | 64 | } |
76 | 65 |
|
| 66 | + @Deprecated(forRemoval = true, since = "6.2.12.Final") |
77 | 67 | static String getTypeString(Class cl) { |
78 | 68 | if (cl == Byte.TYPE) { |
79 | 69 | return "B"; |
@@ -136,7 +126,7 @@ protected void populateMap(Class clazz, ClientConfiguration configuration, Strin |
136 | 126 | if (processor != null) { |
137 | 127 | long hash = 0; |
138 | 128 | try { |
139 | | - hash = methodHash(method); |
| 129 | + hash = MethodHashing.methodHash(method); |
140 | 130 | } catch (Exception e) { |
141 | 131 | throw new RuntimeException(e); |
142 | 132 | } |
|
0 commit comments