jerryshao opened a new issue, #10762:
URL: https://github.com/apache/gravitino/issues/10762

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   `TestVersion` fails when tests are run directly (e.g. `./gradlew 
:common:test`) without first running the `jar` task. The 
`gravitino-build-info.properties` file is only generated inside `common:jar { 
doFirst }`, not during `processResources`. Since `test` does not depend on 
`jar`, the file is absent from the test classpath, causing `Version`'s static 
initializer to throw. All four `TestVersion` test methods fail because loading 
the `Version` class triggers the static `INSTANCE` initialization, even though 
the tests only call `parseVersionNumber()` which never uses `INSTANCE`.
   
   ### Error message and/or stacktrace
   
   ```
   java.lang.ExceptionInInitializerError
       Caused by: org.apache.gravitino.exceptions.GravitinoRuntimeException:
       Failed to get Gravitino version: Build info properties file is missing.
           Caused by: java.io.IOException: Resource 
gravitino-build-info.properties not found
               at org.apache.gravitino.Version.<init>(Version.java:51)
               at org.apache.gravitino.Version.<clinit>(Version.java:41)
   ```
   
   ### How to reproduce
   
   1. Run `./gradlew clean :common:test -PskipITs` (without a prior `./gradlew 
build` or `jar`)
   2. Observe all four `TestVersion` test methods failing
   
   ### Additional context
   
   Two possible fixes:
   - Move `writeProjectPropertiesFile()` from `jar { doFirst }` to a dedicated 
task that `processResources` depends on, so the file is always available for 
tests.
   - Lazy-initialize `Version.INSTANCE` so it is only created when 
`getCurrentVersion()` / `getCurrentVersionDTO()` are called, not when 
`parseVersionNumber()` is called.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to