Skip to content

Commit c941b0b

Browse files
RANGER-4076: Addressed review comment of copilot
1 parent 3979067 commit c941b0b

17 files changed

Lines changed: 642 additions & 164 deletions

File tree

agents-audit/core/src/test/java/org/apache/ranger/audit/utils/RangerJSONAuditWriterTest.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ public void verifyFileRolloverWithAppend() throws Exception {
101101

102102
reset(jsonAuditWriter);
103103

104-
assertTrue(jsonAuditWriter.logJSON(Collections.singleton("Last log file will be opened in append mode and this event will be written")));
105-
assertTrue(jsonAuditWriter.logJSON(Collections.singleton("This event will also be written in append mode")));
106-
Path auditPath1 = jsonAuditWriter.auditPath;
104+
final Path auditPath1;
105+
synchronized (jsonAuditWriter) {
106+
assertTrue(jsonAuditWriter.logJSON(Collections.singleton("Last log file will be opened in append mode and this event will be written")));
107+
assertTrue(jsonAuditWriter.logJSON(Collections.singleton("This event will also be written in append mode")));
108+
auditPath1 = jsonAuditWriter.auditPath;
109+
}
110+
assertNotNull(auditPath1);
107111

108112
Thread.sleep(6000);
109113

@@ -118,6 +122,7 @@ public void verifyFileRolloverWithAppend() throws Exception {
118122

119123
// ensure the same rolled over file is not used for append
120124
assertNotEquals(auditPath1, jsonAuditWriter.auditPath);
125+
assertNotNull(jsonAuditWriter.auditPath, "second write should create a new audit file path");
121126

122127
// cleanup
123128
jsonAuditWriter.fileSystem.deleteOnExit(auditPath1);
@@ -165,14 +170,19 @@ public void verifyFileRolloverAfterThreshold() throws Exception {
165170
jsonAuditWriter.fileRolloverSec = 5; // in seconds
166171
jsonAuditWriter.init(props, "test", "localfs", auditConfigs);
167172

168-
assertTrue(jsonAuditWriter.logJSON(Collections.singleton("First file created and added this line!")));
169-
Path auditPath1 = jsonAuditWriter.auditPath;
173+
final Path auditPath1;
174+
synchronized (jsonAuditWriter) {
175+
assertTrue(jsonAuditWriter.logJSON(Collections.singleton("First file created and added this line!")));
176+
auditPath1 = jsonAuditWriter.auditPath;
177+
}
178+
assertNotNull(auditPath1);
170179

171180
Thread.sleep(6000);
172181

173182
assertNull(jsonAuditWriter.ostream);
174183
assertNull(jsonAuditWriter.logWriter);
175184
assertTrue(jsonAuditWriter.logJSON(Collections.singleton("Second file created since rollover happened!")));
185+
assertNotNull(jsonAuditWriter.auditPath, "second write should create a new audit file path");
176186

177187
// cleanup
178188
jsonAuditWriter.fileSystem.deleteOnExit(auditPath1);

agents-audit/dest-hdfs/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,31 @@
6161
<groupId>org.apache.hadoop</groupId>
6262
<artifactId>hadoop-client-api</artifactId>
6363
<version>${hadoop.version}</version>
64+
<exclusions>
65+
<exclusion>
66+
<groupId>com.sun.jersey</groupId>
67+
<artifactId>*</artifactId>
68+
</exclusion>
69+
<exclusion>
70+
<groupId>com.sun.jersey.contribs</groupId>
71+
<artifactId>*</artifactId>
72+
</exclusion>
73+
</exclusions>
6474
</dependency>
6575
<dependency>
6676
<groupId>org.apache.hadoop</groupId>
6777
<artifactId>hadoop-client-runtime</artifactId>
6878
<version>${hadoop.version}</version>
79+
<exclusions>
80+
<exclusion>
81+
<groupId>com.sun.jersey</groupId>
82+
<artifactId>*</artifactId>
83+
</exclusion>
84+
<exclusion>
85+
<groupId>com.sun.jersey.contribs</groupId>
86+
<artifactId>*</artifactId>
87+
</exclusion>
88+
</exclusions>
6989
</dependency>
7090
<dependency>
7191
<groupId>org.apache.ranger</groupId>

agents-common/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,31 @@
9696
<groupId>org.apache.hadoop</groupId>
9797
<artifactId>hadoop-client-api</artifactId>
9898
<version>${hadoop.version}</version>
99+
<exclusions>
100+
<exclusion>
101+
<groupId>com.sun.jersey</groupId>
102+
<artifactId>*</artifactId>
103+
</exclusion>
104+
<exclusion>
105+
<groupId>com.sun.jersey.contribs</groupId>
106+
<artifactId>*</artifactId>
107+
</exclusion>
108+
</exclusions>
99109
</dependency>
100110
<dependency>
101111
<groupId>org.apache.hadoop</groupId>
102112
<artifactId>hadoop-client-runtime</artifactId>
103113
<version>${hadoop.version}</version>
114+
<exclusions>
115+
<exclusion>
116+
<groupId>com.sun.jersey</groupId>
117+
<artifactId>*</artifactId>
118+
</exclusion>
119+
<exclusion>
120+
<groupId>com.sun.jersey.contribs</groupId>
121+
<artifactId>*</artifactId>
122+
</exclusion>
123+
</exclusions>
104124
</dependency>
105125
<dependency>
106126
<groupId>org.apache.ranger</groupId>

hdfs-agent/pom.xml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,53 @@
204204
</exclusion>
205205
</exclusions>
206206
</dependency>
207+
<dependency>
208+
<groupId>com.sun.jersey</groupId>
209+
<artifactId>jersey-client</artifactId>
210+
<version>1.19.4</version>
211+
<scope>test</scope>
212+
<exclusions>
213+
<exclusion>
214+
<groupId>com.sun.jersey</groupId>
215+
<artifactId>jersey-core</artifactId>
216+
</exclusion>
217+
</exclusions>
218+
</dependency>
219+
<dependency>
220+
<groupId>com.sun.jersey</groupId>
221+
<artifactId>jersey-core</artifactId>
222+
<version>1.19.4</version>
223+
<scope>test</scope>
224+
</dependency>
225+
<dependency>
226+
<groupId>com.sun.jersey</groupId>
227+
<artifactId>jersey-server</artifactId>
228+
<version>1.19.4</version>
229+
<scope>test</scope>
230+
<exclusions>
231+
<exclusion>
232+
<groupId>com.sun.jersey</groupId>
233+
<artifactId>jersey-core</artifactId>
234+
</exclusion>
235+
</exclusions>
236+
</dependency>
207237

208-
<!-- Jersey 1.x for hadoop-minicluster tests (MiniDFSCluster HTTP server needs it) -->
238+
<!-- MiniDFSCluster / NN web stack still uses com.sun.jersey ServletContainer. Jersey 1 is excluded from
239+
compile deps above; this test-only stack is declared direct + test to avoid transitives at compile scope
240+
(which the enforcer rejects). See parent pom bannedDependencies includes for test-scoped com.sun.jersey. -->
209241
<dependency>
210242
<groupId>com.sun.jersey</groupId>
211243
<artifactId>jersey-servlet</artifactId>
212244
<version>1.19.4</version>
213245
<scope>test</scope>
246+
<exclusions>
247+
<exclusion>
248+
<groupId>com.sun.jersey</groupId>
249+
<artifactId>jersey-server</artifactId>
250+
</exclusion>
251+
</exclusions>
214252
</dependency>
253+
215254
<dependency>
216255
<groupId>org.apache.hadoop</groupId>
217256
<artifactId>hadoop-minicluster</artifactId>

hive-agent/pom.xml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@
181181
<artifactId>hive-jdbc</artifactId>
182182
<version>${hive.version}</version>
183183
<exclusions>
184+
<exclusion>
185+
<groupId>com.sun.jersey</groupId>
186+
<artifactId>*</artifactId>
187+
</exclusion>
188+
<exclusion>
189+
<groupId>com.sun.jersey.contribs</groupId>
190+
<artifactId>*</artifactId>
191+
</exclusion>
184192
<exclusion>
185193
<groupId>org.apache.zookeeper</groupId>
186194
<artifactId>zookeeper</artifactId>
@@ -196,6 +204,14 @@
196204
<artifactId>hive-metastore</artifactId>
197205
<version>${hive.version}</version>
198206
<exclusions>
207+
<exclusion>
208+
<groupId>com.sun.jersey</groupId>
209+
<artifactId>*</artifactId>
210+
</exclusion>
211+
<exclusion>
212+
<groupId>com.sun.jersey.contribs</groupId>
213+
<artifactId>*</artifactId>
214+
</exclusion>
199215
<exclusion>
200216
<groupId>io.netty</groupId>
201217
<artifactId>netty-buffer</artifactId>
@@ -223,6 +239,14 @@
223239
<artifactId>hive-service</artifactId>
224240
<version>${hive.version}</version>
225241
<exclusions>
242+
<exclusion>
243+
<groupId>com.sun.jersey</groupId>
244+
<artifactId>*</artifactId>
245+
</exclusion>
246+
<exclusion>
247+
<groupId>com.sun.jersey.contribs</groupId>
248+
<artifactId>*</artifactId>
249+
</exclusion>
226250
<exclusion>
227251
<groupId>io.netty</groupId>
228252
<artifactId>netty</artifactId>
@@ -376,17 +400,31 @@
376400
<artifactId>hadoop-client-runtime</artifactId>
377401
<version>${hadoop.version}</version>
378402
<scope>test</scope>
403+
<exclusions>
404+
<exclusion>
405+
<groupId>com.sun.jersey</groupId>
406+
<artifactId>*</artifactId>
407+
</exclusion>
408+
<exclusion>
409+
<groupId>com.sun.jersey.contribs</groupId>
410+
<artifactId>*</artifactId>
411+
</exclusion>
412+
</exclusions>
379413
</dependency>
380414
<dependency>
381415
<groupId>org.apache.hadoop</groupId>
382416
<artifactId>hadoop-mapreduce-client-core</artifactId>
383417
<version>${hadoop.version}</version>
384418
<scope>test</scope>
385419
<exclusions>
386-
<!-- Exclude Jersey 1.x - project uses Jersey 2.x -->
420+
<!-- Jersey 1.x: exclude entire group (YARN/MR can pull jersey-core, jersey-client, not only jersey-guice) -->
421+
<exclusion>
422+
<groupId>com.sun.jersey</groupId>
423+
<artifactId>*</artifactId>
424+
</exclusion>
387425
<exclusion>
388426
<groupId>com.sun.jersey.contribs</groupId>
389-
<artifactId>jersey-guice</artifactId>
427+
<artifactId>*</artifactId>
390428
</exclusion>
391429
<exclusion>
392430
<groupId>io.netty</groupId>

plugin-nestedstructure/pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
<groupId>org.apache.ranger</groupId>
6969
<artifactId>ranger-plugins-common</artifactId>
7070
<version>${project.version}</version>
71+
<exclusions>
72+
<exclusion>
73+
<groupId>com.sun.jersey</groupId>
74+
<artifactId>*</artifactId>
75+
</exclusion>
76+
<exclusion>
77+
<groupId>com.sun.jersey.contribs</groupId>
78+
<artifactId>*</artifactId>
79+
</exclusion>
80+
</exclusions>
7181
</dependency>
7282
<dependency>
7383
<groupId>org.openjdk.nashorn</groupId>
@@ -80,6 +90,26 @@
8090
<version>${jakarta.ws.rs-api.version}</version>
8191
<scope>provided</scope>
8292
</dependency>
93+
<!-- Jersey 1 is excluded from Hadoop/ranger-plugins-common at compile. Some Hadoop APIs still reference
94+
com.sun.jersey (e.g. ClientHandlerException). Direct test-scoped 1.19.4 with split transitives for enforcer. -->
95+
<dependency>
96+
<groupId>com.sun.jersey</groupId>
97+
<artifactId>jersey-client</artifactId>
98+
<version>1.19.4</version>
99+
<scope>test</scope>
100+
<exclusions>
101+
<exclusion>
102+
<groupId>com.sun.jersey</groupId>
103+
<artifactId>jersey-core</artifactId>
104+
</exclusion>
105+
</exclusions>
106+
</dependency>
107+
<dependency>
108+
<groupId>com.sun.jersey</groupId>
109+
<artifactId>jersey-core</artifactId>
110+
<version>1.19.4</version>
111+
<scope>test</scope>
112+
</dependency>
83113
<dependency>
84114
<groupId>org.junit.jupiter</groupId>
85115
<artifactId>junit-jupiter</artifactId>

0 commit comments

Comments
 (0)