Skip to content

Commit e7567f7

Browse files
authored
Merge pull request #103 from meituan/bugfix/double_scan_bug_fix
[feat] call task 执行多次问题修复
2 parents 21180ba + a1f21be commit e7567f7

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

WmPlugin/baseplugin/src/main/java/com/kronos/plugin/base/BaseTransform.kt

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import java.util.concurrent.Executors
1717
import java.util.concurrent.ForkJoinPool
1818

1919
class BaseTransform(
20-
transformInvocation: TransformInvocation?,
21-
callBack: TransformCallBack,
22-
single: Boolean = false
20+
transformInvocation: TransformInvocation?,
21+
callBack: TransformCallBack,
22+
single: Boolean = false
2323
) {
2424
private var mCallBack: TransformCallBack? = callBack
2525
var context: Context? = null
@@ -70,8 +70,8 @@ class BaseTransform(
7070
}
7171
/*获得输出文件*/
7272
val dest = outputProvider!!.getContentLocation(
73-
destName + "_" + hexName,
74-
jarInput.contentTypes, jarInput.scopes, Format.JAR
73+
destName + "_" + hexName,
74+
jarInput.contentTypes, jarInput.scopes, Format.JAR
7575
)
7676
if (isIncremental) {
7777
when (status) {
@@ -113,8 +113,8 @@ class BaseTransform(
113113
@Throws(IOException::class)
114114
private fun foreachClass(directoryInput: DirectoryInput) {
115115
val dest = outputProvider!!.getContentLocation(
116-
directoryInput.name, directoryInput.contentTypes,
117-
directoryInput.scopes, Format.DIRECTORY
116+
directoryInput.name, directoryInput.contentTypes,
117+
directoryInput.scopes, Format.DIRECTORY
118118
)
119119
destFiles.add(dest)
120120
val map = directoryInput.changedFiles
@@ -135,7 +135,7 @@ class BaseTransform(
135135
null
136136
}
137137
tasks.add(callable)
138-
executor.submit(callable)
138+
// executor.submit(callable)
139139
}
140140
Status.REMOVED -> deleteDirectory(destFile, dest)
141141
else -> {
@@ -171,8 +171,8 @@ class BaseTransform(
171171
try {
172172
if (classFile.name.endsWith(".class")) {
173173
val absolutePath = classFile.absolutePath.replace(
174-
dest.absolutePath +
175-
File.separator, ""
174+
dest.absolutePath +
175+
File.separator, ""
176176
)
177177
val className = ClassUtils.path2Classname(absolutePath)
178178
val bytes = IOUtils.toByteArray(FileInputStream(classFile))
@@ -188,8 +188,8 @@ class BaseTransform(
188188
private fun modifySingleFile(dir: File, file: File, dest: File) {
189189
try {
190190
val absolutePath = file.absolutePath.replace(
191-
dir.absolutePath +
192-
File.separator, ""
191+
dir.absolutePath +
192+
File.separator, ""
193193
)
194194
val className = ClassUtils.path2Classname(absolutePath)
195195
if (absolutePath.endsWith(".class")) {
@@ -236,7 +236,7 @@ class BaseTransform(
236236
if (classFile.name.endsWith(".class")) {
237237
val task = Callable<Void> {
238238
val absolutePath = classFile.absolutePath.replace(
239-
dir.absolutePath + File.separator, ""
239+
dir.absolutePath + File.separator, ""
240240
)
241241
val className = ClassUtils.path2Classname(absolutePath)
242242
if (!simpleScan) {
@@ -249,7 +249,6 @@ class BaseTransform(
249249
null
250250
}
251251
tasks.add(task)
252-
executor.submit(task)
253252
}
254253
}
255254
}
@@ -275,7 +274,8 @@ class BaseTransform(
275274
val task = Callable<Void> {
276275
try {
277276
if (!simpleScan) {
278-
val modifiedJar = JarUtils.modifyJarFile(jarInput.file, context?.temporaryDir, this)
277+
val modifiedJar =
278+
JarUtils.modifyJarFile(jarInput.file, context?.temporaryDir, this)
279279
FileUtils.copyFile(modifiedJar, dest)
280280
} else {
281281
val jarFile = jarInput.file
@@ -291,7 +291,6 @@ class BaseTransform(
291291
null
292292
}
293293
tasks.add(task)
294-
executor.submit(task)
295294
}
296295

297296
private fun diffJar(dest: File, jarInput: JarInput) {

0 commit comments

Comments
 (0)