Migrate to Platform 2.7.3 and Java 21#211
Conversation
| */ | ||
| protected int getTargetPage(HttpServletRequest request, int currentPage) { | ||
| return WebUtils.getTargetPage(request, PARAM_TARGET, currentPage); | ||
| Enumeration<String> parameterNames = request.getParameterNames(); |
There was a problem hiding this comment.
Do you mind pointing me to where you got this implementation?
There was a problem hiding this comment.
I kinda based this on the original implementation
public static int getTargetPage(ServletRequest request, String paramPrefix, int currentPage) {
Enumeration<String> paramNames = request.getParameterNames();
while(paramNames.hasMoreElements()) {
String paramName = (String)paramNames.nextElement();
if (paramName.startsWith(paramPrefix)) {
for(int i = 0; i < SUBMIT_IMAGE_SUFFIXES.length; ++i) {
String suffix = SUBMIT_IMAGE_SUFFIXES[i];
if (paramName.endsWith(suffix)) {
paramName = paramName.substring(0, paramName.length() - suffix.length());
}
}
return Integer.parseInt(paramName.substring(paramPrefix.length()));
}
}
return currentPage;
}
There was a problem hiding this comment.
Just going to the source using the IDE.
There was a problem hiding this comment.
That one includes a logic to remove the submit button image suffixes. I did not include that here. Should I add that?
There was a problem hiding this comment.
Which version of spring did you copy it from?
There was a problem hiding this comment.
The version the module was using: Spring 4.1.4 RELEASE
There was a problem hiding this comment.
But what you have is different from where you copied it: https://github.com/spring-projects/spring-framework/blob/v4.3.30.RELEASE/spring-web/src/main/java/org/springframework/web/util/WebUtils.java#L698-L713
|
You would need to create a branch of the module for older platform versions. |
I created the 1.x branch and also updated the development version to 2.0.0-SNAPSHOT: 53c7372 |
|
@dkayiwa don't merge this yet, I just noticed this is not running all the tests correctly. |
We can get the tests to run by either removing the parent element or updating the maven-parent artifact and setting the version to the latest snapshot of that artifact: cc: @ibacher |
I have switched the bamboo CI build from the master to the 1.x branch. |
|
@dkayiwa I'm running into an issue with the findCountAndPatients_shouldMatchPatientWithIdentifiersThatContainNoDigit test. The method getCountOfPatients doesn't return a match for the search query unless I set the includeVoided argument to true—even though the patient identifier being searched for isn’t voided. I was also able to reproduce the same behavior in core by writing a test directly there |
|
Is the test failure triggered by simply switching the platform version? |
Yeah |
|
@dkayiwa I fixed the test errors. |
omod/pom.xml
Outdated
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> |
There was a problem hiding this comment.
Do we really need these bytebuddy dependencies?
There was a problem hiding this comment.
Yeah, we need it for Mockito. I think after we migrate the Core to a newer version of Mockito we could remove this from here.
There was a problem hiding this comment.
There was a problem hiding this comment.
What error do you get when you remove them from just here?
There was a problem hiding this comment.
[ERROR] ConceptFormBackingObject_shouldCopyNumericAttributes Time elapsed: 0.175 s <<< ERROR!
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class org.openmrs.ConceptNumeric.
If you're not sure why you're getting this error, please report to the mailing list.
Java : 21
JVM vendor name : Amazon.com Inc.
JVM vendor version : 21.0.6+7-LTS
JVM name : OpenJDK 64-Bit Server VM
JVM version : 21.0.6+7-LTS
JVM info : mixed mode, sharing
OS name : Linux
OS version : 6.1.0-32-amd64
You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.
Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [interface org.openmrs.OpenmrsObject, class java.lang.Object, class org.openmrs.ConceptNumeric, interface org.openmrs.Auditable, interface java.io.Serializable, interface org.openmrs.customdatatype.Customizable, class org.openmrs.Concept, interface org.openmrs.Changeable, class org.openmrs.BaseOpenmrsObject, interface org.openmrs.Creatable, interface org.openmrs.Attributable, interface org.openmrs.Retireable]
at org.openmrs.web.controller.concept.ConceptFormControllerTest.ConceptFormBackingObject_shouldCopyNumericAttributes(ConceptFormControllerTest.java:25)
Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [interface org.openmrs.OpenmrsObject, class java.lang.Object, class org.openmrs.ConceptNumeric, interface org.openmrs.Auditable, interface java.io.Serializable, interface org.openmrs.customdatatype.Customizable, class org.openmrs.Concept, interface org.openmrs.Changeable, class org.openmrs.BaseOpenmrsObject, interface org.openmrs.Creatable, interface org.openmrs.Attributable, interface org.openmrs.Retireable]
at org.openmrs.web.controller.concept.ConceptFormControllerTest.ConceptFormBackingObject_shouldCopyNumericAttributes(ConceptFormControllerTest.java:25)
Caused by: java.lang.IllegalStateException:
Byte Buddy could not instrument all classes within the mock's type hierarchy
This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
- Compiled by older versions of scalac
- Classes that are part of the Android distribution
at org.openmrs.web.controller.concept.ConceptFormControllerTest.ConceptFormBackingObject_shouldCopyNumericAttributes(ConceptFormControllerTest.java:25)
Caused by: java.lang.IllegalArgumentException: Java 21 (65) is not supported by the current version of Byte Buddy which officially supports Java 20 (64) - update Byte Buddy or set net.bytebuddy.experimental as a VM property
at org.openmrs.web.controller.concept.ConceptFormControllerTest.ConceptFormBackingObject_shouldCopyNumericAttributes(ConceptFormControllerTest.java:25)
There was a problem hiding this comment.
Did you see my comment about removing them from only that file?
There was a problem hiding this comment.
are you referring to "mockito-inline"?
There was a problem hiding this comment.
We need it to do static mocks without using powermock.
There was a problem hiding this comment.
What i mean is, i put a comment in a specific file to remove the bytebuddy dependencies from only that file. Can you do that and commit?
There was a problem hiding this comment.
Ohh ok. I updated that and it is working now :)
| <concept_description concept_description_id="5090" concept_id="5090" description="Patient's height in kilograms." locale="en" creator="1" date_created="2004-08-12 00:00:00.0" uuid="18ae66c9-cd2e-429d-9c6d-29bd5805dcf8"/> | ||
| <concept_name concept_id="5090" name="HEIGHT (KG)" locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="1439" voided="false" uuid="4302daf5-acc8-4173-b766-bed42ae79e06" concept_name_type="FULLY_SPECIFIED" locale_preferred="0"/> | ||
| <concept_numeric concept_id="5090" hi_normal="250.0" low_critical="0.0" units="cm" precise="true"/> | ||
| <concept_numeric concept_id="5090" hi_normal="250.0" low_critical="0.0" units="cm" display_precision="true" allow_decimal="true" /> |
There was a problem hiding this comment.
Do we really need the display_precision?
|
|
||
| //will be sending the alert via ajax, so we need to escape js special chars | ||
| model.put("alertMessage", JavaScriptUtils.javaScriptEscape(alertMessage)); | ||
| if(alertMessage != null) { |
There was a problem hiding this comment.
| // Remove any image button suffixes (like .x or .y) | ||
| if (param.endsWith(suffix)) { | ||
| param = param.substring(0, param.length() - suffix.length()); | ||
| break; |
There was a problem hiding this comment.
We do not have this break in the original code.
| try { | ||
| return Integer.parseInt(pageStr); | ||
| } | ||
| catch (NumberFormatException e) { |
There was a problem hiding this comment.
The original code does not catch this exception.
|
@dkayiwa I updated the PR. |
| <dependency> | ||
| <groupId>net.bytebuddy</groupId> | ||
| <artifactId>byte-buddy</artifactId> | ||
| <version>1.17.4</version> |
|
@wikumChamith basing on the approach which have taken for the addresshierarchy module, is there anything that prevents us from running or compiling this on Java 8 too? |
No. We can support both Java 21 and Java 8 for this module. |
|
So can we do the needful? |
Updated module to Java 21 and Platform 2.7.3. Replaced WebUtils#getTargetPage, which was removed in newer Spring versions, with a custom implementation.
Ticket: https://openmrs.atlassian.net/browse/LUI-200