Skip to content

Commit

Permalink
Merge branch 'support-java-16'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaisiKoleni committed Mar 19, 2021
2 parents 7add572 + 434ef7f commit 160b0fe
Show file tree
Hide file tree
Showing 30 changed files with 1,153 additions and 364 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [11, 12, 13, 14, 15]
java: [11, 12, 13, 14, 15, 16]
name: Java ${{ matrix.java }} Run
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 0 additions & 6 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
</natures>
</projectDescription>
17 changes: 15 additions & 2 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
org.eclipse.jdt.core.formatter.align_with_spaces=false
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0
org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assertion_message=0
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
Expand Down Expand Up @@ -47,6 +58,7 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declarati
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
Expand Down Expand Up @@ -371,6 +383,7 @@ org.eclipse.jdt.core.formatter.text_block_indentation=0
org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
Expand Down
121 changes: 119 additions & 2 deletions .settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
@@ -1,9 +1,126 @@
cleanup.add_all=true
cleanup.add_default_serial_version_id=false
cleanup.add_generated_serial_version_id=true
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=false
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=true
cleanup.always_use_blocks=false
cleanup.always_use_parentheses_in_expressions=true
cleanup.always_use_this_for_non_static_field_access=false
cleanup.always_use_this_for_non_static_method_access=false
cleanup.arrays_fill=true
cleanup.bitwise_conditional_expression=true
cleanup.boolean_literal=true
cleanup.break_loop=true
cleanup.collection_cloning=true
cleanup.comparing_on_criteria=true
cleanup.comparison_statement=true
cleanup.controlflow_merge=true
cleanup.convert_functional_interfaces=true
cleanup.convert_to_enhanced_for_loop=true
cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true
cleanup.convert_to_switch_expressions=false
cleanup.correct_indentation=true
cleanup.double_negation=true
cleanup.else_if=true
cleanup.embedded_if=true
cleanup.evaluate_nullable=true
cleanup.extract_increment=false
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.hash=true
cleanup.if_condition=true
cleanup.insert_inferred_type_arguments=false
cleanup.instanceof=false
cleanup.invert_equals=true
cleanup.join=true
cleanup.lazy_logical_operator=true
cleanup.make_local_variable_final=false
cleanup.make_parameters_final=false
cleanup.make_private_fields_final=true
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=true
cleanup.map_cloning=true
cleanup.merge_conditional_blocks=true
cleanup.multi_catch=true
cleanup.never_use_blocks=true
cleanup.never_use_parentheses_in_expressions=false
cleanup.no_string_creation=true
cleanup.no_super=true
cleanup.number_suffix=true
cleanup.objects_equals=true
cleanup.organize_imports=true
cleanup.overridden_assignment=true
cleanup.plain_replacement=true
cleanup.precompile_regex=true
cleanup.primitive_comparison=true
cleanup.primitive_parsing=true
cleanup.primitive_serialization=true
cleanup.pull_up_assignment=true
cleanup.push_down_negation=true
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.reduce_indentation=true
cleanup.redundant_falling_through_block_end=true
cleanup.remove_private_constructors=true
cleanup.remove_redundant_modifiers=true
cleanup.remove_redundant_semicolons=true
cleanup.remove_redundant_type_arguments=true
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_array_creation=true
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true
cleanup.remove_unused_local_variables=true
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.simplify_lambda_expression_and_method_ref=true
cleanup.single_used_field=true
cleanup.sort_members=false
cleanup.sort_members_all=false
cleanup.standard_comparison=false
cleanup.static_inner_class=true
cleanup.strictly_equal_or_different=true
cleanup.stringbuilder=true
cleanup.substring=true
cleanup.switch=true
cleanup.ternary_operator=true
cleanup.try_with_resource=true
cleanup.unlooped_while=true
cleanup.unreachable_block=true
cleanup.use_anonymous_class_creation=false
cleanup.use_autoboxing=true
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_directly_map_method=true
cleanup.use_lambda=true
cleanup.use_parentheses_in_expressions=false
cleanup.use_this_for_non_static_field_access=true
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
cleanup.use_this_for_non_static_method_access=true
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup.use_unboxing=true
cleanup.use_var=false
cleanup.useless_continue=true
cleanup.useless_return=true
cleanup_profile=_Basic
cleanup_settings_version=2
eclipse.preferences.version=1
formatter_profile=_Eclipse adjusted
formatter_settings_version=19
formatter_settings_version=21
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=java;javax;org;com;net;ch;info;de.tum;
org.eclipse.jdt.ui.importorder=java;javax;junit;org;com;net;ch;info;de.tum;
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.staticondemandthreshold=2
org.eclipse.jdt.ui.text.custom_code_templates=
49 changes: 16 additions & 33 deletions src/main/java/de/tum/in/test/api/internal/ReportingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import java.util.Objects;
import java.util.Optional;
import java.util.function.UnaryOperator;

import org.junit.jupiter.api.extension.InvocationInterceptor.Invocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.tum.in.test.api.internal.sanitization.MessageTransformer;
import de.tum.in.test.api.internal.sanitization.ThrowableInfo;
import de.tum.in.test.api.internal.sanitization.ThrowableSanitizer;
import de.tum.in.test.api.localization.Messages;
import de.tum.in.test.api.security.ArtemisSecurityManager;
Expand Down Expand Up @@ -47,34 +48,29 @@ public static Throwable processThrowable(Throwable t, TestContext context) {
}

private static Throwable processThrowableRegularly(Throwable t) {
Throwable newT = trySanitizeThrowable(t);
tryPostProcessMessageOrAddSuppressed(newT, ReportingUtils::postProcessMessage);
if (!(newT instanceof AssertionError)) {
addStackframeInfoToMessage(newT);
}
return newT;
return trySanitizeThrowable(t, ReportingUtils::transformMessage);
}

private static Throwable processThrowablePrivilegedOnly(Throwable t, String nonprivilegedFailureMessage) {
Throwable newT;
if (t instanceof PrivilegedException)
newT = trySanitizeThrowable(t);
else
newT = new AssertionError(nonprivilegedFailureMessage);
tryPostProcessMessageOrAddSuppressed(t, ReportingUtils::postProcessMessage);
return newT;
return trySanitizeThrowable(t, ReportingUtils::transformMessage);
return new AssertionError(nonprivilegedFailureMessage);
}

private static Throwable trySanitizeThrowable(Throwable t) {
private static Throwable trySanitizeThrowable(Throwable t, MessageTransformer messageTransformer) {
String name = "unknown";
Throwable newT;
try {
name = t.getClass().getName();
newT = ThrowableSanitizer.sanitize(t);
return ThrowableSanitizer.sanitize(t, messageTransformer);
} catch (Throwable sanitizationError) {
return handleSanitizationFailure(name, sanitizationError);
}
return newT;
}

private static String transformMessage(ThrowableInfo info) {
if (!AssertionError.class.isAssignableFrom(info.getClass()))
addStackframeInfoToMessage(info);
return info.getMessage();
}

private static Throwable handleSanitizationFailure(String name, Throwable error) {
Expand All @@ -83,26 +79,13 @@ private static Throwable handleSanitizationFailure(String name, Throwable error)
return new SecurityException(name + " thrown, but cannot be displayed: " + info + "");
}

private static void addStackframeInfoToMessage(Throwable newT) {
StackTraceElement[] stackTrace = BlacklistedInvoker.invoke(newT::getStackTrace);
private static void addStackframeInfoToMessage(ThrowableInfo info) {
StackTraceElement[] stackTrace = info.getStackTrace();
var first = ArtemisSecurityManager.firstNonWhitelisted(stackTrace);
if (first.isPresent()) {
String call = first.get().toString();
tryPostProcessMessageOrAddSuppressed(newT, old -> Objects.toString(old, "") + "\n"
info.setMessage(Objects.toString(info.getMessage(), "") + "\n"
+ Messages.formatLocalized("reporting.problem_location_hint", call));
}
}

private static String tryPostProcessMessageOrAddSuppressed(Throwable t, UnaryOperator<String> transform) {
String newMessage = transform.apply(ThrowableUtils.getDetailMessage(t));
ThrowableUtils.setDetailMessage(t, newMessage);
return newMessage;
}

/**
* This is currently just returning the message with normalized newlines
*/
private static String postProcessMessage(String message) {
return message == null ? null : message.replace("\r", "");
}
}
84 changes: 0 additions & 84 deletions src/main/java/de/tum/in/test/api/internal/ThrowableUtils.java

This file was deleted.

Loading

0 comments on commit 160b0fe

Please sign in to comment.