LockFileTest failure
See original GitHub issueLooking at the test, because the integer update is not an atomic get-and-set, I think it’s prone to failure.
[INFO] Running com.google.cloud.tools.jib.filesystem.LockFileTest
Exception in thread "Thread-1" java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at com.google.cloud.tools.jib.filesystem.LockFileTest.lambda$testLockAndRelease$0(LockFileTest.java:41)
at java.lang.Thread.run(Thread.java:748)
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.117 s <<< FAILURE! - in com.google.cloud.tools.jib.filesystem.LockFileTest
[ERROR] testLockAndRelease(com.google.cloud.tools.jib.filesystem.LockFileTest) Time elapsed: 0.115 s <<< FAILURE!
java.lang.AssertionError: expected:<2> but was:<1>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at com.google.cloud.tools.jib.filesystem.LockFileTest.testLockAndRelease(LockFileTest.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Windows Server 2019: LockFile lock is not released by OS ...
Try to open it with Visual Studio Code, it fails with the error EBUSY. The file remains locked even though the owning process...
Read more >How do I fix a lock file mismatch? - Barracuda Campus
The lock file is an authentication measure the Intronis software uses to ensure backups are being taken of the right machine.
Read more >file locking - Fcntl in go doesn't work - Stack Overflow
If I create the file with touch lockfiletest.lock , that is with no file contents, your program fails with your error: error locking...
Read more >Ubuntu root can't give any permissions?
Output: Error writing lock file ./.test.sh.swp: Permission denied. Giving an user account its own permissions:
Read more >Lock Files in PHP & Bash
With the implementation described in the post at abhinavsingh.com, it will fail if you put it as a background process as an example...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Things to check:
Try deleting the file while holding the lock. If deletion doesn’t fail, that may explain https://github.com/GoogleContainerTools/jib/issues/1695#issuecomment-489740855 and we need to do something different.
Assuming the deletion fails: I also see the warning in my IDE that the
FileOutputStream
is never closed. Will closing the stream also close the channel (and subsequently releasing the lock)?If that is the case, garbage collection may be the cause and we should prevent that.
This came to our surprise. Perhaps
FileChannel
locks a region of the channel’s file and cannot prevent other processes from deleting the file itself, I don’t know. I can’t think of a better way than not deleting the lock file at all in our implementation.