diff options
| author | 2021-06-08 23:54:26 +0200 | |
|---|---|---|
| committer | 2021-06-08 23:54:26 +0200 | |
| commit | bc1f9854c8ce06ecf8ded0eb3c4079929786e3f4 (patch) | |
| tree | a990d0e0f5856172c945866eb2cb3b0a9fb3fdee | |
| parent | Bump version. (diff) | |
| download | enigma-bc1f9854c8ce06ecf8ded0eb3c4079929786e3f4.tar.gz enigma-bc1f9854c8ce06ecf8ded0eb3c4079929786e3f4.tar.xz enigma-bc1f9854c8ce06ecf8ded0eb3c4079929786e3f4.zip | |
Fix some exceptions getting silently discarded (e.g. see #398)
| -rw-r--r-- | enigma/src/main/java/cuchaz/enigma/classhandle/ClassHandleProvider.java | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/enigma/src/main/java/cuchaz/enigma/classhandle/ClassHandleProvider.java b/enigma/src/main/java/cuchaz/enigma/classhandle/ClassHandleProvider.java index f56e908d..229d18a8 100644 --- a/enigma/src/main/java/cuchaz/enigma/classhandle/ClassHandleProvider.java +++ b/enigma/src/main/java/cuchaz/enigma/classhandle/ClassHandleProvider.java | |||
| @@ -246,13 +246,7 @@ public final class ClassHandleProvider { | |||
| 246 | return CompletableFuture.supplyAsync(() -> { | 246 | return CompletableFuture.supplyAsync(() -> { |
| 247 | if (decompileVersion.get() != v) return null; | 247 | if (decompileVersion.get() != v) return null; |
| 248 | 248 | ||
| 249 | Result<Source, ClassHandleError> _uncommentedSource; | 249 | Result<Source, ClassHandleError> uncommentedSource = Result.ok(p.decompiler.getSource(entry.getFullName())); |
| 250 | try { | ||
| 251 | _uncommentedSource = Result.ok(p.decompiler.getSource(entry.getFullName())); | ||
| 252 | } catch (Throwable e) { | ||
| 253 | return Result.err(ClassHandleError.decompile(e)); | ||
| 254 | } | ||
| 255 | Result<Source, ClassHandleError> uncommentedSource = _uncommentedSource; | ||
| 256 | Entry.this.uncommentedSource = uncommentedSource; | 250 | Entry.this.uncommentedSource = uncommentedSource; |
| 257 | Entry.this.waitingUncommentedSources.forEach(f -> f.complete(uncommentedSource)); | 251 | Entry.this.waitingUncommentedSources.forEach(f -> f.complete(uncommentedSource)); |
| 258 | Entry.this.waitingUncommentedSources.clear(); | 252 | Entry.this.waitingUncommentedSources.clear(); |
| @@ -281,26 +275,22 @@ public final class ClassHandleProvider { | |||
| 281 | DecompiledClassSource source = new DecompiledClassSource(entry, index); | 275 | DecompiledClassSource source = new DecompiledClassSource(entry, index); |
| 282 | return Result.ok(source); | 276 | return Result.ok(source); |
| 283 | }); | 277 | }); |
| 284 | }, p.pool); | 278 | }, p.pool).exceptionally(e -> Result.err(ClassHandleError.decompile(e))); |
| 285 | } | 279 | } |
| 286 | 280 | ||
| 287 | private void continueMapSource(CompletableFuture<Result<DecompiledClassSource, ClassHandleError>> f) { | 281 | private void continueMapSource(CompletableFuture<Result<DecompiledClassSource, ClassHandleError>> f) { |
| 288 | int v = mappedVersion.incrementAndGet(); | 282 | int v = mappedVersion.incrementAndGet(); |
| 289 | f.thenAcceptAsync(res -> { | 283 | f.thenApplyAsync(res -> { |
| 290 | if (res == null || mappedVersion.get() != v) return; | 284 | if (res == null || mappedVersion.get() != v) return null; |
| 291 | res = res.andThen(source -> { | 285 | return res.andThen(source -> Result.ok(source.remapSource(p.project, p.project.getMapper().getDeobfuscator()))); |
| 292 | try { | 286 | }, p.pool).whenComplete((res, e) -> { |
| 293 | DecompiledClassSource remappedSource = source.remapSource(p.project, p.project.getMapper().getDeobfuscator()); | 287 | if (e != null) res = Result.err(ClassHandleError.remap(e)); |
| 294 | return Result.ok(remappedSource); | 288 | if (res == null) return; |
| 295 | } catch (Throwable e) { | ||
| 296 | return Result.err(ClassHandleError.remap(e)); | ||
| 297 | } | ||
| 298 | }); | ||
| 299 | Entry.this.source = res; | 289 | Entry.this.source = res; |
| 300 | Entry.this.waitingSources.forEach(s -> s.complete(source)); | 290 | Entry.this.waitingSources.forEach(s -> s.complete(source)); |
| 301 | Entry.this.waitingSources.clear(); | 291 | Entry.this.waitingSources.clear(); |
| 302 | withLock(lock.readLock(), () -> new ArrayList<>(handles)).forEach(h -> h.onMappedSourceChanged(source)); | 292 | withLock(lock.readLock(), () -> new ArrayList<>(handles)).forEach(h -> h.onMappedSourceChanged(source)); |
| 303 | }, p.pool); | 293 | }); |
| 304 | } | 294 | } |
| 305 | 295 | ||
| 306 | public void closeHandle(ClassHandleImpl classHandle) { | 296 | public void closeHandle(ClassHandleImpl classHandle) { |