-
Notifications
You must be signed in to change notification settings - Fork 7
Make study crosstab report more robust #7342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
labkey-adam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggesitons... none required
| statSet.add(Stats.VAR); | ||
| else if ("Median".equals(stat)) | ||
| statSet.add(Stats.MEDIAN); | ||
| ResultSetUtil.close(results); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try-with-resources instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try-with-resources is kinda clunky when it comes to potentially null values, so I went with this direction.
| else if ("Var".equals(stat)) | ||
| statSet.add(Stats.VAR); | ||
| else if ("Median".equals(stat)) | ||
| statSet.add(Stats.MEDIAN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old code, but seems so clunky. Especially when we have (unused) Stats.getStatFromString()... though we should probably switch ALL_STATS to a Map<String, StatDefinition> to improve this. Not required for this PR, of course.
| builder.addOption(col.getLabel(), col.getFieldKey().encode()) | ||
| .selected(null != selected && selected.equalsIgnoreCase(col.getFieldKey().encode())); | ||
| builder.addOption(new OptionBuilder(col.getLabel(), col.getFieldKey().encode()) | ||
| .selected(null != selected && selected.equalsIgnoreCase(col.getFieldKey().encode()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a problem with the previous code? Looks equivalent but more verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. addOption() returns the SelectBuilder so the old code called selected() on that, passing true or false. Those aren't the values of any options, so nothing was selected. This change calls selected() on the OptionBuilder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha... subtle, I misinterpreted the parens.
Rationale
Recent scans on nightly.labkey.com caused a connection leak on requests to
study-reports-participantCrosstab.view. We can do better at validating parameters and handling theResultsobject, though I was unable to repro the leak locally.Example URLs from the scanner in this log file:
https://gist.githubusercontent.com/labkey-jony/541e4f1582918f63f05f46ca8f349f90/raw/3e5ad715159f407bf6e1a3b75469471f3018b8b0/threaddump.log
Changes
Tasks 📍