Environment Details
- Transformer Version: 0.5.0
- JDK version: openjdk 11.0.12
- OS: Red Hat Enterprise Linux 7.4
Problem Description
Transformer does not convert the javax to jakarta in ValidationMessages.properties and its internationalized files (For example, ValidationMessages_ja.properties).
They are used by Jakarta Bean Validation.
Steps to reproduce
It is reproducible by specifying ValidationMessages.properties like below.
javax.validation.constraints.NotNull.message=must not be null
The key name will contain javax and must be converted to jakarta.
Cause
In the class used in the property file conversion, only the conversion logic of the file name exists, and there is no logic to convert the contents of the file.
|
public ByteData apply(ByteData inputData) throws TransformException { |
|
startRecording(inputData.name()); |
|
try { |
|
String outputName = transformBinaryType(inputData.name()); |
|
if (outputName != null) { |
|
getLogger().debug("Properties file {}, relocated to {}", inputData.name(), outputName); |
|
setResourceNames(inputData.name(), outputName); |
|
return new ByteDataImpl(outputName, inputData.buffer()); |
|
} |
|
setResourceNames(inputData.name(), inputData.name()); |
|
return inputData; |
|
} finally { |
|
stopRecording(inputData.name()); |
|
} |
|
} |
When the file extension is .properties, transformer should check and convert the contents of the file in the similar way it replaces the text file with TextActionImpl.
|
public ByteData apply(ByteData inputData) throws TransformException { |
|
String inputName = inputData.name(); |
|
startRecording(inputName); |
|
try { |
|
String outputName = relocateResource(inputName); |
|
|
|
setResourceNames(inputName, outputName); |
|
|
|
ByteBufferOutputStream outputStream = new ByteBufferOutputStream(inputData.length()); |
|
|
|
try (BufferedReader reader = reader(inputData.buffer()); BufferedWriter writer = writer(outputStream)) { |
|
transform(inputName, reader, writer); |
|
} catch (IOException e) { |
|
throw new TransformException("Failed to transform [ " + inputName + " ]", e); |
|
} |
|
|
|
if (!hasChanges()) { |
|
return inputData; |
|
} |
|
|
|
ByteBuffer outputBuffer = hasNonResourceNameChanges() ? outputStream.toByteBuffer() : inputData.buffer(); |
|
ByteData outputData = new ByteDataImpl(outputName, outputBuffer); |
|
return outputData; |
|
} finally { |
|
stopRecording(inputName); |
|
} |
|
} |