[ 
https://issues.apache.org/jira/browse/IGNITE-28863?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmitry Werner updated IGNITE-28863:
-----------------------------------
    Description: 
*Root Cause*

All 7 GridFileDeploymentSelfTest failures stem from a duplicate entry in 
deployfile-bad-signed.jar.

The pom.xml build script intentionally creates a corrupted JAR for testing bad 
signature verification:

1. Copies `GridUriDeploymentTestTask11.class` under the name 
`GridUriDeploymentTestWithNameTask11.class` (bytecode contains `this_class = 
GridUriDeploymentTestTask11` → mismatch with filename)

2. Packs this corrupted class into JAR, signs it, then **updates** the JAR with 
the correct class:
{code:java}
 <zip destfile="...${bad-signed.jar}" basedir=".../target/classes/"
     includes=".../GridUriDeploymentTestWithNameTask11.class" update="yes" 
/>{code}
 

The problem: `ant zip update="yes"` behavior changed in Ant 1.9+. Instead of 
**replacing** an existing entry, it appends a duplicate at the end of the 
archive. The JAR now contains two entries with the same name:
- First entry (corrupted, `this_class = GridUriDeploymentTestTask11`) — loaded 
by `URLClassLoader`
- Second entry (correct, `this_class = GridUriDeploymentTestWithNameTask11`) — 
never reached

On JDK 17, `URLClassLoader.findClass()` loads the first (corrupted) entry → JVM 
throws `NoClassDefFoundError: wrong name`. This crashes the `grid-uri-scanner` 
thread, stopping all subsequent deployments. All `checkTask()` assertions fail 
with `findResource() == null`.

The same issue exists for `bad-signed-deployfile.gar` with 
`GridUriDeploymentTestWithNameTask6`.

*Fix*

Replace `ant zip update="yes"` with the standard unzip → copy → zip pattern 
that works reliably across all Ant versions:
{code:java}
 <unzip src=".../${bad-signed.jar}" dest="${basedir}/target/file_tmp/zipfix" />
<copy 
file="${basedir}/target/classes/.../GridUriDeploymentTestWithNameTask11.class"
      todir="${basedir}/target/file_tmp/zipfix/..." overwrite="yes" />
<delete file=".../${bad-signed.jar}" />
<zip destfile=".../${bad-signed.jar}" 
basedir="${basedir}/target/file_tmp/zipfix" />{code}
Applied to both `deployfile-bad-signed.jar` and `bad-signed-deployfile.gar`.

  was:
## Root Cause

All 7 `GridFileDeploymentSelfTest` failures stem from a **duplicate entry** in 
`deployfile-bad-signed.jar`.

The `pom.xml` build script intentionally creates a corrupted JAR for testing 
bad signature verification:

1. Copies `GridUriDeploymentTestTask11.class` under the name 
`GridUriDeploymentTestWithNameTask11.class` (bytecode contains `this_class = 
GridUriDeploymentTestTask11` → mismatch with filename)
2. Packs this corrupted class into JAR, signs it, then **updates** the JAR with 
the correct class:

```xml
<zip destfile="...${bad-signed.jar}" basedir=".../target/classes/"
     includes=".../GridUriDeploymentTestWithNameTask11.class" update="yes" />
```

**The problem:** `ant zip update="yes"` behavior changed in Ant 1.9+. Instead 
of **replacing** an existing entry, it **appends** a duplicate at the end of 
the archive. The JAR now contains **two entries** with the same name:
- First entry (corrupted, `this_class = GridUriDeploymentTestTask11`) — loaded 
by `URLClassLoader`
- Second entry (correct, `this_class = GridUriDeploymentTestWithNameTask11`) — 
never reached

On JDK 17, `URLClassLoader.findClass()` loads the first (corrupted) entry → JVM 
throws `NoClassDefFoundError: wrong name`. This crashes the `grid-uri-scanner` 
thread, stopping all subsequent deployments. All `checkTask()` assertions fail 
with `findResource() == null`.

The same issue exists for `bad-signed-deployfile.gar` with 
`GridUriDeploymentTestWithNameTask6`.

## Fix

Replace `ant zip update="yes"` with the standard **unzip → copy → zip** pattern 
that works reliably across all Ant versions:

```xml
<unzip src=".../${bad-signed.jar}" dest="${basedir}/target/file_tmp/zipfix" />
<copy 
file="${basedir}/target/classes/.../GridUriDeploymentTestWithNameTask11.class"
      todir="${basedir}/target/file_tmp/zipfix/..." overwrite="yes" />
<delete file=".../${bad-signed.jar}" />
<zip destfile=".../${bad-signed.jar}" 
basedir="${basedir}/target/file_tmp/zipfix" />
```

Applied to both `deployfile-bad-signed.jar` and `bad-signed-deployfile.gar`.


> Fix flaky GridFileDeploymentSelfTest
> ------------------------------------
>
>                 Key: IGNITE-28863
>                 URL: https://issues.apache.org/jira/browse/IGNITE-28863
>             Project: Ignite
>          Issue Type: Test
>            Reporter: Dmitry Werner
>            Assignee: Dmitry Werner
>            Priority: Minor
>              Labels: MakeTeamcityGreenAgain, ise
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> *Root Cause*
> All 7 GridFileDeploymentSelfTest failures stem from a duplicate entry in 
> deployfile-bad-signed.jar.
> The pom.xml build script intentionally creates a corrupted JAR for testing 
> bad signature verification:
> 1. Copies `GridUriDeploymentTestTask11.class` under the name 
> `GridUriDeploymentTestWithNameTask11.class` (bytecode contains `this_class = 
> GridUriDeploymentTestTask11` → mismatch with filename)
> 2. Packs this corrupted class into JAR, signs it, then **updates** the JAR 
> with the correct class:
> {code:java}
>  <zip destfile="...${bad-signed.jar}" basedir=".../target/classes/"
>      includes=".../GridUriDeploymentTestWithNameTask11.class" update="yes" 
> />{code}
>  
> The problem: `ant zip update="yes"` behavior changed in Ant 1.9+. Instead of 
> **replacing** an existing entry, it appends a duplicate at the end of the 
> archive. The JAR now contains two entries with the same name:
> - First entry (corrupted, `this_class = GridUriDeploymentTestTask11`) — 
> loaded by `URLClassLoader`
> - Second entry (correct, `this_class = GridUriDeploymentTestWithNameTask11`) 
> — never reached
> On JDK 17, `URLClassLoader.findClass()` loads the first (corrupted) entry → 
> JVM throws `NoClassDefFoundError: wrong name`. This crashes the 
> `grid-uri-scanner` thread, stopping all subsequent deployments. All 
> `checkTask()` assertions fail with `findResource() == null`.
> The same issue exists for `bad-signed-deployfile.gar` with 
> `GridUriDeploymentTestWithNameTask6`.
> *Fix*
> Replace `ant zip update="yes"` with the standard unzip → copy → zip pattern 
> that works reliably across all Ant versions:
> {code:java}
>  <unzip src=".../${bad-signed.jar}" dest="${basedir}/target/file_tmp/zipfix" 
> />
> <copy 
> file="${basedir}/target/classes/.../GridUriDeploymentTestWithNameTask11.class"
>       todir="${basedir}/target/file_tmp/zipfix/..." overwrite="yes" />
> <delete file=".../${bad-signed.jar}" />
> <zip destfile=".../${bad-signed.jar}" 
> basedir="${basedir}/target/file_tmp/zipfix" />{code}
> Applied to both `deployfile-bad-signed.jar` and `bad-signed-deployfile.gar`.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to