Fix hang
This commit is contained in:
parent
2dd47e4dbe
commit
8a38642793
|
|
@ -145,8 +145,9 @@ public class ModernFixCachingClassTransformer extends ClassTransformer {
|
||||||
/* We only want to cache actual transformations */
|
/* We only want to cache actual transformations */
|
||||||
if(ITransformerActivity.CLASSLOADING_REASON.equals(reason)) {
|
if(ITransformerActivity.CLASSLOADING_REASON.equals(reason)) {
|
||||||
final byte[] classToHash = inputClass;
|
final byte[] classToHash = inputClass;
|
||||||
CompletableFuture<ArrayList<byte[]>> futureHashList = CompletableFuture.supplyAsync(() -> computeHash(className, classToHash, reason), ForkJoinPool.commonPool());
|
ArrayList<byte[]> hashList = computeHash(className, classToHash, reason);
|
||||||
ArrayList<byte[]> hashList = null;
|
if(hashList == null)
|
||||||
|
return super.transform(inputClass, className, reason);
|
||||||
/* Check if the cache contains a transformed class matching these hashes */
|
/* Check if the cache contains a transformed class matching these hashes */
|
||||||
/* TODO maybe sanitize the class name? */
|
/* TODO maybe sanitize the class name? */
|
||||||
File cacheLocation = new File(CLASS_CACHE_FOLDER, className.replace('.', '/'));
|
File cacheLocation = new File(CLASS_CACHE_FOLDER, className.replace('.', '/'));
|
||||||
|
|
@ -154,7 +155,6 @@ public class ModernFixCachingClassTransformer extends ClassTransformer {
|
||||||
try(ObjectInputStream stream = new ObjectInputStream(new FileInputStream(cacheLocation))) {
|
try(ObjectInputStream stream = new ObjectInputStream(new FileInputStream(cacheLocation))) {
|
||||||
ArrayList<byte[]> savedHash = (ArrayList<byte[]>)stream.readObject();
|
ArrayList<byte[]> savedHash = (ArrayList<byte[]>)stream.readObject();
|
||||||
byte[] savedInputClass = (byte[])stream.readObject();
|
byte[] savedInputClass = (byte[])stream.readObject();
|
||||||
hashList = futureHashList.get();
|
|
||||||
if(hashList != null) {
|
if(hashList != null) {
|
||||||
for(int i = 0; i < savedHash.size(); i++) {
|
for(int i = 0; i < savedHash.size(); i++) {
|
||||||
if(!Arrays.equals(savedHash.get(i), hashList.get(i))) {
|
if(!Arrays.equals(savedHash.get(i), hashList.get(i))) {
|
||||||
|
|
@ -166,8 +166,7 @@ public class ModernFixCachingClassTransformer extends ClassTransformer {
|
||||||
hashesMatch = false;
|
hashesMatch = false;
|
||||||
if(hashesMatch)
|
if(hashesMatch)
|
||||||
inputClass = savedInputClass;
|
inputClass = savedInputClass;
|
||||||
} catch(IOException | ClassNotFoundException | ClassCastException | InterruptedException |
|
} catch(IOException | ClassNotFoundException | ClassCastException e) {
|
||||||
ExecutionException e) {
|
|
||||||
if(!(e instanceof FileNotFoundException))
|
if(!(e instanceof FileNotFoundException))
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
hashesMatch = false;
|
hashesMatch = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user