-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
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
[MyPerf4J-90] Fix SysGenProfilingFile rename fail #90 #91
base: develop
Are you sure you want to change the base?
Conversation
MyPerf4J-Core/src/main/java/cn/myperf4j/core/MethodMetricsHistogram.java
Outdated
Show resolved
Hide resolved
MyPerf4J-Core/src/main/java/cn/myperf4j/core/MethodMetricsHistogram.java
Outdated
Show resolved
Hide resolved
fileWriter.write("#This is a file automatically generated by MyPerf4J, please do not edit!\n"); | ||
fileWriter.flush(); | ||
// 流还没释放导致 | ||
Assert.assertFalse(tmpFilePath.toFile().renameTo(testFilePath1.toFile())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 MacOS 里这行代码执行失败
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你之前的代码在 MacOS 里能成功吗?
Assert.assertTrue(testFilePath2.toFile().setReadOnly()); | ||
} else { | ||
// 第一次rename能成功,后续就失败 | ||
Assert.assertFalse(tmpFilePath.toFile().renameTo(testFilePath2.toFile())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 MacOS 里这行代码执行失败
final File tempFile = buildTmpProfilingFile(filePath); | ||
final Path destPath = Files.move(tempFile.toPath(), Paths.get(filePath), REPLACE_EXISTING); | ||
final File destFile = destPath.toFile(); | ||
// 此处不能设置只读,否则在windows环境下次move的时候会报错 AccessDeniedException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 destFile.setReadOnly() 之后再次 move 会报错的话,那 FileTest 的第 89 行就会抛异常
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不一样,FileTest 能跑成功,但是 agent 加载到 tomcat 里面就会报错
What is the purpose of the change
fix #90
Brief ChangeLog
fix SysGenProfilingFile rename fail
Verifying this change
Follow this checklist to help us incorporate your contribution quickly and easily:
[MyPerf4J-XXX] Fix NullPointerException when host is null #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean package -Dmaven.test.skip=false
to make sure unit-test pass.