Skip to content

Commit 6d82a07

Browse files
committed
Merge branch 'bug37031303-inspect-patches' into 'main'
Bug 37031303 inspect patches dropping last patch when no trailing semicolon See merge request weblogic-cloud/weblogic-image-tool!482
2 parents 143fa84 + a61fffe commit 6d82a07

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/inspect/InventoryPatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public String description() {
3434
public static List<InventoryPatch> parseInventoryPatches(String patchesString) {
3535
List<InventoryPatch> patches = new ArrayList<>();
3636
// Pattern defines a tuple of three elements: patch ID, patch UID, and patch description.
37-
Pattern tuplePattern = Pattern.compile("(\\d+);(\\d+);\\\"(.*?)\\\";");
37+
Pattern tuplePattern = Pattern.compile("(\\d+);(\\d+);\\\"(.*?)\\\";?");
3838
Matcher patchMatcher = tuplePattern.matcher(patchesString);
3939
while (patchMatcher.find()) {
4040
InventoryPatch patch = new InventoryPatch();

imagetool/src/main/java/com/oracle/weblogic/imagetool/logging/FileFormatter.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ private String replaceColorTokens(String text) {
6363
/**
6464
* Formats the log record.
6565
*
66-
* @param record the log record
66+
* @param rec the log record
6767
* @return the formatted log record
6868
*/
6969
@Override
70-
public synchronized String format(LogRecord record) {
70+
public synchronized String format(LogRecord rec) {
7171
StringBuilder sb = new StringBuilder();
7272

73-
date.setTime(record.getMillis());
73+
date.setTime(rec.getMillis());
7474
args[0] = date;
7575

7676
StringBuffer text = new StringBuffer();
@@ -79,28 +79,28 @@ public synchronized String format(LogRecord record) {
7979

8080
// Level
8181
sb.append(" <");
82-
sb.append(record.getLevel().getLocalizedName());
82+
sb.append(rec.getLevel().getLocalizedName());
8383
sb.append(">");
8484

8585
// Class name
8686
sb.append(" <");
87-
String source = record.getSourceClassName();
87+
String source = rec.getSourceClassName();
8888
if (source != null) {
8989
sb.append(source.substring(source.lastIndexOf('.') + 1));
9090
} else {
91-
sb.append(record.getLoggerName());
91+
sb.append(rec.getLoggerName());
9292
}
9393
sb.append(">");
9494

9595
// Method name
9696
sb.append(" <");
97-
if (record.getSourceMethodName() != null) {
98-
sb.append(record.getSourceMethodName());
97+
if (rec.getSourceMethodName() != null) {
98+
sb.append(rec.getSourceMethodName());
9999
}
100100
sb.append(">");
101101

102-
String messageKey = record.getMessage();
103-
String message = replaceColorTokens(formatMessage(record));
102+
String messageKey = rec.getMessage();
103+
String message = replaceColorTokens(formatMessage(rec));
104104

105105
if (messageKey != null) {
106106
sb.append(" <");
@@ -111,11 +111,11 @@ public synchronized String format(LogRecord record) {
111111
}
112112
sb.append(" <");
113113
sb.append(message);
114-
if (record.getThrown() != null) {
114+
if (rec.getThrown() != null) {
115115
try {
116116
StringWriter sw = new StringWriter();
117117
PrintWriter pw = new PrintWriter(sw);
118-
record.getThrown().printStackTrace(pw);
118+
rec.getThrown().printStackTrace(pw);
119119
pw.close();
120120
sb.append(LINE_SEPARATOR);
121121
sb.append(sw.toString());

imagetool/src/test/java/com/oracle/weblogic/imagetool/inspect/InspectTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
package com.oracle.weblogic.imagetool.inspect;
55

66
import java.io.BufferedReader;
7-
import java.io.FileInputStream;
87
import java.io.FileReader;
98
import java.io.IOException;
109
import java.io.InputStream;
1110
import java.io.StringReader;
11+
import java.nio.file.Files;
12+
import java.nio.file.Paths;
1213
import java.util.Properties;
1314

1415
import org.junit.jupiter.api.Tag;
@@ -25,8 +26,8 @@ void testPatchStringParser() {
2526
assertEquals(1, InventoryPatch.parseInventoryPatches("30319071;23384603;\"One-off\";").size());
2627
assertEquals(3, InventoryPatch.parseInventoryPatches(
2728
"30319071;23384603;\"One-off\";26355633;21447583;\"One-off\";26287183;21447582;\"One-off\";").size());
28-
// same as previous but with last semi-colon removed. last patch should be discarded but shouldn't fail.
29-
assertEquals(2, InventoryPatch.parseInventoryPatches(
29+
// same as previous but with last semicolon removed, parser should return same number of patches.
30+
assertEquals(3, InventoryPatch.parseInventoryPatches(
3031
"30319071;23384603;\"One-off\";26355633;21447583;\"One-off\";26287183;21447582;\"One-off\"").size());
3132
}
3233

@@ -50,7 +51,7 @@ void testMoreProperties() throws IOException {
5051

5152
void testPropertiesToJson(String propsFile, String jsonFile) throws IOException {
5253
Properties loaded = new Properties();
53-
try (InputStream input = new FileInputStream(propsFile)) {
54+
try (InputStream input = Files.newInputStream(Paths.get(propsFile))) {
5455
loaded.load(input);
5556
}
5657

tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class ITImagetool {
5252

5353
// STAGING_DIR - directory where JDK and other installers are pre-staged before testing
5454
private static final String STAGING_DIR = System.getProperty("STAGING_DIR");
55-
private static final String wlsImgBldDir = System.getProperty("WLSIMG_BLDDIR");
56-
private static final String wlsImgCacheDir = System.getProperty("WLSIMG_CACHEDIR");
55+
private static final String BLDDIR_ENV = System.getProperty("WLSIMG_BLDDIR");
56+
private static final String CACHEDIR_ENV = System.getProperty("WLSIMG_CACHEDIR");
5757

5858
// Docker images
5959
private static String DB_IMAGE = System.getProperty("DB_IMAGE");
@@ -74,7 +74,7 @@ class ITImagetool {
7474
private static final String WLS_VERSION = "12.2.1.3.0";
7575
private static final String OPATCH_VERSION = "13.9.4.2.2";
7676
private static final String JDK_VERSION = "8u202";
77-
private static final String JDK_VERSION_8u212 = "8u212";
77+
private static final String JDK_VERSION_212 = "8u212";
7878
private static final String WDT_VERSION = "1.1.2";
7979
private static final Path WDT_ARCHIVE = Paths.get("target", "wdt", "archive.zip");
8080
private static final Path WDT_RESOURCES = Paths.get("src", "test", "resources", "wdt");
@@ -92,11 +92,11 @@ private static void validateEnvironmentSettings() {
9292
logger.info("Initializing the tests ...");
9393

9494
List<String> missingSettings = new ArrayList<>();
95-
if (Utils.isEmptyString(wlsImgBldDir)) {
95+
if (Utils.isEmptyString(BLDDIR_ENV)) {
9696
missingSettings.add("WLSIMG_BLDDIR");
9797
}
9898

99-
if (Utils.isEmptyString(wlsImgCacheDir)) {
99+
if (Utils.isEmptyString(CACHEDIR_ENV)) {
100100
missingSettings.add("WLSIMG_CACHEDIR");
101101
}
102102

@@ -129,8 +129,8 @@ private static void validateEnvironmentSettings() {
129129
}
130130
dbContainerName = "InfraDB4" + build_tag;
131131
logger.info("build_tag = " + build_tag);
132-
logger.info("WLSIMG_BLDDIR = " + wlsImgBldDir);
133-
logger.info("WLSIMG_CACHEDIR = " + wlsImgCacheDir);
132+
logger.info("WLSIMG_BLDDIR = " + BLDDIR_ENV);
133+
logger.info("WLSIMG_CACHEDIR = " + CACHEDIR_ENV);
134134
logger.info("STAGING_DIR = " + STAGING_DIR);
135135
logger.info("DB_IMAGE = " + DB_IMAGE);
136136
logger.info("JRE_IMAGE = " + JRE_IMAGE);
@@ -208,10 +208,10 @@ static void staticPrepare() throws Exception {
208208

209209
logger.info("Setting up the test environment ...");
210210

211-
if (!(new File(wlsImgBldDir)).exists()) {
212-
logger.info(wlsImgBldDir + " does not exist, creating it");
213-
if (!(new File(wlsImgBldDir)).mkdir()) {
214-
throw new IllegalStateException("Unable to create build directory " + wlsImgBldDir);
211+
if (!(new File(BLDDIR_ENV)).exists()) {
212+
logger.info(BLDDIR_ENV + " does not exist, creating it");
213+
if (!(new File(BLDDIR_ENV)).mkdir()) {
214+
throw new IllegalStateException("Unable to create build directory " + BLDDIR_ENV);
215215
}
216216
}
217217

@@ -706,7 +706,7 @@ void createMiiOl8slim(TestInfo testInfo) throws Exception {
706706

707707
// test assumes that the default JDK version 8u202 is already in the cache
708708

709-
Path tmpWdtModel = Paths.get(wlsImgBldDir, WDT_MODEL1);
709+
Path tmpWdtModel = Paths.get(BLDDIR_ENV, WDT_MODEL1);
710710

711711
// update wdt model file
712712
Files.copy(WDT_RESOURCES.resolve(WDT_MODEL1), tmpWdtModel, StandardCopyOption.REPLACE_EXISTING);
@@ -788,7 +788,7 @@ void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception {
788788
// add jdk 8u212 installer to the cache
789789
String addNewJdkCmd = new CacheCommand().addInstaller(true)
790790
.type("jdk")
791-
.version(JDK_VERSION_8u212)
791+
.version(JDK_VERSION_212)
792792
.path(Paths.get(STAGING_DIR, JDK_INSTALLER_NEWER))
793793
.build();
794794

@@ -801,7 +801,7 @@ void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception {
801801
// create an image with FMW and the latest PSU using ARU to download the patch
802802
String command = new CreateCommand()
803803
.tag(tagName)
804-
.jdkVersion(JDK_VERSION_8u212)
804+
.jdkVersion(JDK_VERSION_212)
805805
.type("fmw")
806806
.user(oracleSupportUsername)
807807
.passwordEnv("ORACLE_SUPPORT_PASSWORD")
@@ -835,7 +835,7 @@ void createJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception {
835835

836836
// test assumes that the default JDK version 8u202 is already in the cache
837837

838-
Path tmpWdtModel = Paths.get(wlsImgBldDir, WDT_MODEL1);
838+
Path tmpWdtModel = Paths.get(BLDDIR_ENV, WDT_MODEL1);
839839

840840
// update wdt model file
841841
Files.copy(WDT_RESOURCES.resolve(WDT_MODEL1), tmpWdtModel, StandardCopyOption.REPLACE_EXISTING);

0 commit comments

Comments
 (0)