We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fun ZipFile.transform( output: OutputStream, entryFactory: (ZipEntry) -> ZipArchiveEntry = ::ZipArchiveEntry, transformer: (ByteArray) -> ByteArray = { it -> it } ) { val entries = mutableSetOf<String>() val creator = ParallelScatterZipCreator(ThreadPoolExecutor(NCPU, NCPU, 0L, TimeUnit.MILLISECONDS, LinkedBlockingQueue<Runnable>(), Executors.defaultThreadFactory(), RejectedExecutionHandler { runnable, _ -> runnable.run() })) entries().asSequence().filterNot { isJarSignatureRelatedFiles(it.name) }.forEach { entry -> if (!entries.contains(entry.name)) { val zae = entryFactory(entry) val stream = InputStreamSupplier { when (entry.name.substringAfterLast('.', "")) { "class" -> getInputStream(entry).use { src -> try { src.transform(transformer).inputStream() } catch (e: Throwable) { System.err.println("Broken class: ${this.name}!/${entry.name}") getInputStream(entry) } } else -> getInputStream(entry) } } creator.addArchiveEntry(zae, stream) entries.add(entry.name) } else { System.err.println("Duplicated jar entry: ${this.name}!/${entry.name}") } } ZipArchiveOutputStream(output).use(creator::writeTo) }
这里把 transform catch 住了,只是打印了一下 Broken class,不利于排查 transform 失败的原因。这里能否不 catch 异常,而是让异常抛出来呢?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这里把 transform catch 住了,只是打印了一下 Broken class,不利于排查 transform 失败的原因。这里能否不 catch 异常,而是让异常抛出来呢?
The text was updated successfully, but these errors were encountered: