Skip to content

Commit 5701fe2

Browse files
authored
detect OPatch patch in --patches list even if it has an underscore (#221)
1 parent 1c62a80 commit 5701fe2

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cachestore/OPatchFile.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ private static String getLatestCachedVersion(CacheStore cache, String patchId) {
7676
return latestVersion;
7777
}
7878

79+
/**
80+
* Return true if the patchId matches any known OPatch bug numbers.
81+
*
82+
* @param patchId the patch ID to test
83+
* @return true if and only if the patchId matches an OPatch bug number.
84+
*/
85+
public static boolean isOPatchPatch(String patchId) {
86+
if (DEFAULT_BUG_NUM.equals(patchId)) {
87+
return true;
88+
}
89+
return patchId != null && patchId.startsWith(DEFAULT_BUG_NUM + CacheStore.CACHE_KEY_SEPARATOR);
90+
}
91+
7992
@Override
8093
public String resolve(CacheStore cacheStore) throws IOException {
8194
try {

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void handlePatchFiles(FmwInstallerType installerType, String previousInventory,
295295
// add user-provided patch list to any patches that were found for latestPsu or recommendedPatches
296296
for (String patchId : patches) {
297297
// if user mistakenly added the OPatch patch to the WLS patch list, skip it
298-
if (OPatchFile.DEFAULT_BUG_NUM.equals(patchId)) {
298+
if (OPatchFile.isOPatchPatch(patchId)) {
299299
continue;
300300
}
301301
// if patch ID was provided as bugnumber_version, split the bugnumber and version strings
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.oracle.weblogic.imagetool.cachestore;
5+
6+
import org.junit.jupiter.api.Tag;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static org.junit.jupiter.api.Assertions.assertFalse;
10+
import static org.junit.jupiter.api.Assertions.assertTrue;
11+
12+
@Tag("unit")
13+
public class OPatchFileTest {
14+
@Test
15+
void opatchPatchIdTest() {
16+
assertTrue(OPatchFile.isOPatchPatch("28186730"), "OPatch bug number");
17+
assertTrue(OPatchFile.isOPatchPatch("28186730_13.9.4.2.4"), "OPatch bug number with version");
18+
assertTrue(OPatchFile.isOPatchPatch("28186730_1"), "OPatch bug number with separator");
19+
20+
assertFalse(OPatchFile.isOPatchPatch("28186731"), "Should not match");
21+
assertFalse(OPatchFile.isOPatchPatch("281867301"), "OPatch bug number with additional number");
22+
}
23+
}

0 commit comments

Comments
 (0)