Incorrect detection of NAR files
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
**Describe the bug**
In several parts of the code (`org.apache.pulsar.common.nar.FileUtils`, `NarClassLoader`, ...), the type of the archive (NAR or JAR) is detected by looking at the existence of the `META-INF/bundled-dependencies` directory. But this directory doesn't necessarily exist in a NAR archive. For instance, if all the dependencies of the artifact are set as `provided` because they already exist in Pulsar. In that case the archive gets wrongly detected as a JAR.
**To Reproduce**
Steps to reproduce the behavior:
1. Create new maven project ExclamationFunction
```java
public class ExclamationFunction implements Function {
@Override
public String process(String input, Context context) {
return String.format("%s!", input);
}
}
```
2. Write pom including nifi-nar-maven-plugin
```xml
4.0.0
com.example
exclamation-function
1.0-SNAPSHOT
org.apache.nifi
nifi-nar-maven-plugin
1.2.0
true
${project.artifactId}-${project.version}
default-nar
package
nar
org.apache.maven.plugins
maven-compiler-plugin
8
8
```
3. Package
```sh
mvn clean package
```
4. Inspect the generated NAR --> There is no `META-INF/bundled-dependencies` directory
**Expected behavior**
Another way to detect if the archive is a NAR should be used.
Eg. checking if the `MANIFEST.MF` file contains the string `Nar-Id:`
Contributor guide
Research direction
Start in org.apache.pulsar.common.nar.FileUtils and NarClassLoader, where archive type detection is described as checking META-INF/bundled-dependencies. Reproduce with the provided Maven NAR project, then verify detection using the MANIFEST.MF Nar-Id entry for archives without that directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100