Skip to content

PathResourceTests.lastModified() fails on Linux [SPR-13542] #18118

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

Closed
spring-projects-issues opened this issue Oct 6, 2015 · 3 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Suematsu Shinya opened SPR-13542 and commented

org.springframework.core.io.PathResourceTests.lastModified() failed on Linux.
I use Red Hat Enterprise Linux 7.0 and ext4.

java.lang.AssertionError:
Expected: <1443699122000L>
     but: was <1443699122561L>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.junit.Assert.assertThat(Assert.java:956)
        at org.junit.Assert.assertThat(Assert.java:923)
        at org.springframework.core.io.PathResourceTests.lastModified(PathResour
ceTests.java:226)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
Method.java:50)

In my environment, java.io.File.lastModified() returns a value truncated by seconds.
But PathResource.lastModified() returns a msec value.


Affects: 4.1.7, 4.2.1

Attachments:

Referenced from: commits be90f7d, 9cf2895

Backported to: 4.1.8

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I suppose we can make that test more reliable by truncating the return value to seconds ourselves and comparing it that way. We're not in the business of dealing with such file system subtleties, after all...

For PathResource.lastModified() itself, it seems to be alright to return the most specific value possible. User code should not make hard assumptions about the milliseconds part there, so neither should our unit tests.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Suematsu Shinya commented

Does it mean this test is too severe?
I ignore this test at a while if the test is not important.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, that test is simply too strict. I've relaxed it to compare seconds precision only.

Juergen

@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.2.2 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants