diff options
author | Alexander Kurtakov | 2018-06-07 08:57:20 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-06-07 08:57:20 +0000 |
commit | 1c26af582a12646a42c7b2bd96e8fa257204d8ff (patch) | |
tree | 01c5991985c058000564d25489ed8eaa385941c8 | |
parent | d327fa362c43c139dee7958fb55ae76ec5a25f55 (diff) | |
download | rt.equinox.p2-1c26af582a12646a42c7b2bd96e8fa257204d8ff.tar.gz rt.equinox.p2-1c26af582a12646a42c7b2bd96e8fa257204d8ff.tar.xz rt.equinox.p2-1c26af582a12646a42c7b2bd96e8fa257204d8ff.zip |
Bug 535636 - Update bundles to Java 1.8
Take care of various modernizations and updates in p2.testserver.
Change-Id: Id5ad446c1cab4cf81702a28e976c41a41070cd58
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
24 files changed, 457 insertions, 268 deletions
diff --git a/bundles/org.eclipse.equinox.p2.testserver/.classpath b/bundles/org.eclipse.equinox.p2.testserver/.classpath index 64c5e31b7..eca7bdba8 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/.classpath +++ b/bundles/org.eclipse.equinox.p2.testserver/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.core.prefs index 6b947078c..97d2ee121 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,3 @@ -#Thu Apr 23 14:57:34 CEST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.builder.cleanOutputFolder=clean org.eclipse.jdt.core.builder.duplicateResourceTask=warning @@ -8,17 +7,28 @@ org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch org.eclipse.jdt.core.circularClasspath=error org.eclipse.jdt.core.classpath.exclusionPatterns=enabled org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000 +org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -27,7 +37,8 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning @@ -35,6 +46,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning @@ -45,7 +57,9 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled @@ -54,28 +68,48 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore @@ -84,19 +118,25 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=error org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 +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.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 @@ -105,17 +145,25 @@ org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 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_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 @@ -135,26 +183,36 @@ org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false -org.eclipse.jdt.core.formatter.comment.format_line_comments=false +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false org.eclipse.jdt.core.formatter.comment.indent_root_tags=false org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false org.eclipse.jdt.core.formatter.compact_else_if=true org.eclipse.jdt.core.formatter.continuation_indentation=2 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true @@ -164,10 +222,18 @@ org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert @@ -175,7 +241,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do no org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert @@ -186,7 +252,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert @@ -215,10 +281,11 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=inser org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert @@ -233,12 +300,14 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invoca org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert @@ -247,7 +316,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert @@ -262,11 +331,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invoc org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert @@ -289,6 +359,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do n org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -317,6 +388,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invoc org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert @@ -326,6 +398,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=inser org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -335,19 +408,37 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=800 +org.eclipse.jdt.core.formatter.lineSplit=120 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.ui.prefs index 9cdad0ea3..5cde36397 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.ui.prefs +++ b/bundles/org.eclipse.equinox.p2.testserver/.settings/org.eclipse.jdt.ui.prefs @@ -1,8 +1,7 @@ -#Thu Apr 23 14:20:17 CEST 2009 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_core -formatter_settings_version=11 +formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile +formatter_settings_version=14 org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=; org.eclipse.jdt.ui.ondemandthreshold=20 @@ -11,22 +10,29 @@ sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.convert_functional_interfaces=true +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=true sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true @@ -34,7 +40,9 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class= sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_redundant_modifiers=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true @@ -47,8 +55,10 @@ sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true diff --git a/bundles/org.eclipse.equinox.p2.testserver/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.testserver/META-INF/MANIFEST.MF index d69ad11a0..11bffb25c 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.testserver/META-INF/MANIFEST.MF @@ -2,13 +2,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Testserver Bundle-SymbolicName: org.eclipse.equinox.p2.testserver;singleton:=true -Bundle-Version: 1.0.100.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Activator: org.eclipse.equinox.p2.testserver.Activator Bundle-Vendor: Eclipse -Bundle-RequiredExecutionEnvironment: J2SE-1.5, - J2SE-1.4 -Import-Package: org.eclipse.equinox.http, - org.osgi.framework;version="1.3.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.osgi.framework;version="1.3.0" Bundle-ActivationPolicy: lazy Require-Bundle: javax.servlet;bundle-version="2.4.0", org.eclipse.equinox.http.registry, diff --git a/bundles/org.eclipse.equinox.p2.testserver/pom.xml b/bundles/org.eclipse.equinox.p2.testserver/pom.xml index cee562d15..964d49897 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/pom.xml +++ b/bundles/org.eclipse.equinox.p2.testserver/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.p2.testserver</artifactId> - <version>1.0.100-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java index 2a3b43c2d..8213d971e 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,9 +32,9 @@ import org.osgi.service.http.NamespaceException; import org.osgi.util.tracker.ServiceTracker; import org.osgi.util.tracker.ServiceTrackerCustomizer; -public class Activator implements BundleActivator, ServiceTrackerCustomizer { +public class Activator implements BundleActivator, ServiceTrackerCustomizer<HttpService, HttpService> { private static BundleContext context; - private ServiceTracker httpTracker; + private ServiceTracker<HttpService, ?> httpTracker; private SecureContext secureHttpContext; private SecuredArtifactsContext artifactSecuredHttpContext; private static Activator instance; @@ -46,21 +46,24 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer { private static final String SITE2 = "http://www.eclipse.org/equinox/p2/testing/updateSite"; //$NON-NLS-1$ private static final String SITE3 = "http://download.eclipse.org/eclipse/updates/3.5-I-builds/"; //$NON-NLS-1$ + @Override public void start(BundleContext aContext) throws Exception { context = aContext; - httpTracker = new ServiceTracker(context, HttpService.class.getName(), this); + httpTracker = new ServiceTracker<>(context, HttpService.class, this); httpTracker.open(); instance = this; } + @Override public void stop(BundleContext aContext) throws Exception { httpTracker.close(); context = null; } - public Object addingService(ServiceReference reference) { - httpService = (HttpService) context.getService(reference); + @Override + public HttpService addingService(ServiceReference<HttpService> reference) { + httpService = context.getService(reference); secureHttpContext = new SecureContext(httpService.createDefaultHttpContext()); artifactSecuredHttpContext = new SecuredArtifactsContext(httpService.createDefaultHttpContext()); alwaysFail = new AlwaysFailContext(httpService.createDefaultHttpContext()); @@ -72,23 +75,33 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer { httpService.registerResources("/private", "/webfiles", secureHttpContext); //$NON-NLS-1$ //$NON-NLS-2$ httpService.registerResources("/never", "/webfiles", alwaysFail); //$NON-NLS-1$ //$NON-NLS-2$ httpService.registerResources("/flipflop", "/webfiles", flipFlop); //$NON-NLS-1$ //$NON-NLS-2$ - // httpService.registerResources("/mirrorrequest", "/webfiles/emptyJarRepo", null); //$NON-NLS-1$ //$NON-NLS-2$ + // httpService.registerResources("/mirrorrequest", "/webfiles/emptyJarRepo", + // null); //$NON-NLS-1$ //$NON-NLS-2$ httpService.registerServlet("/status", new StatusCodeResponse(), null, null); //$NON-NLS-1$ httpService.registerServlet("/timeout", new TimeOut(), null, null); //$NON-NLS-1$ - httpService.registerServlet("/mirrorrequest", new IntermittentTimeout("/mirrorrequest", URI.create("http://localhost:" + System.getProperty("org.osgi.service.http.port", "8080") + "/public/emptyJarRepo")), null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + httpService.registerServlet("/mirrorrequest", //$NON-NLS-1$ + new IntermittentTimeout("/mirrorrequest", URI.create("http://localhost:" //$NON-NLS-1$ //$NON-NLS-2$ + + System.getProperty("org.osgi.service.http.port", "8080") + "/public/emptyJarRepo")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + null, null); httpService.registerServlet("/redirect", new Redirector(), null, null); //$NON-NLS-1$ - httpService.registerServlet("/truncated", new Truncator("/truncated", URI.create("/webfiles"), 50), null, null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - httpService.registerServlet("/molested", new FileMolester("/molested", URI.create("/webfiles"), 40), null, null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + httpService.registerServlet("/truncated", new Truncator("/truncated", URI.create("/webfiles"), 50), null, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + null); + httpService.registerServlet("/molested", new FileMolester("/molested", URI.create("/webfiles"), 40), null, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + null); // 8 bytes at a time, delay from 0 to 100 ms, in steps of 5 - httpService.registerServlet("/decelerate", new ChopAndDelay("/decelerate", URI.create("/webfiles"), 3, 0, new LinearChange(0, 5, 100, 0)), null, null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + httpService.registerServlet("/decelerate", //$NON-NLS-1$ + new ChopAndDelay("/decelerate", URI.create("/webfiles"), 3, 0, new LinearChange(0, 5, 100, 0)), //$NON-NLS-1$//$NON-NLS-2$ + null, null); addProxyServices(httpService, SITE, "/proxy/"); //$NON-NLS-1$ addProxyServices(httpService, SITE2, "/proxy2/"); //$NON-NLS-1$ - httpService.registerServlet("/proxy3/aprivate", new BasicResourceDelivery("/proxy3/aprivate", URI.create(SITE2)), null, artifactSecuredHttpContext); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet("/proxy4/aprivate", new BasicResourceDelivery("/proxy4/aprivate", URI.create(SITE3)), null, artifactSecuredHttpContext); //$NON-NLS-1$//$NON-NLS-2$ + httpService.registerServlet("/proxy3/aprivate", //$NON-NLS-1$ + new BasicResourceDelivery("/proxy3/aprivate", URI.create(SITE2)), null, artifactSecuredHttpContext); //$NON-NLS-1$ + httpService.registerServlet("/proxy4/aprivate", //$NON-NLS-1$ + new BasicResourceDelivery("/proxy4/aprivate", URI.create(SITE3)), null, artifactSecuredHttpContext); //$NON-NLS-1$ httpService.registerServlet("/stats", new Stats(), null, null); //$NON-NLS-1$ } catch (NamespaceException e) { @@ -103,33 +116,55 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer { /** * Adds services to a location + * * @param site * @param root the "mount dir" e.g. "/proxy/" "/proxy2/" etc. - * @throws NamespaceException - * @throws ServletException + * @throws NamespaceException + * @throws ServletException */ - private void addProxyServices(HttpService httpService, String site, String root) throws ServletException, NamespaceException { - httpService.registerServlet(root + "truncated", new Truncator(root + "truncated", URI.create(site), 50), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "public", new BasicResourceDelivery(root + "public", URI.create(site)), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "private", new BasicResourceDelivery(root + "private", URI.create(site)), null, secureHttpContext); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "never", new BasicResourceDelivery(root + "private", URI.create(site)), null, alwaysFail); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "flipFlop", new BasicResourceDelivery(root + "private", URI.create(site)), null, flipFlop); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "molested", new FileMolester(root + "molested", URI.create(site), 40), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "decelerate", new ChopAndDelay(root + "decelerate", URI.create(site), 3, 0, new LinearChange(0, 5, 100, 0)), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "decelerate2", new ChopAndDelay(root + "decelerate2", URI.create(site), 3, 80, new LinearChange(100, 5, 105, 0)), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "readtimeout", new ChopAndDelay(root + "readtimeout", URI.create(site), 3, 10, new LinearChange(10 * 60 * 1000, 5, 5 + 10 * 60 * 1000, 0)), null, null); //$NON-NLS-1$//$NON-NLS-2$ + private void addProxyServices(HttpService service, String site, String root) + throws ServletException, NamespaceException { + service.registerServlet(root + "truncated", new Truncator(root + "truncated", URI.create(site), 50), null, //$NON-NLS-1$//$NON-NLS-2$ + null); + service.registerServlet(root + "public", new BasicResourceDelivery(root + "public", URI.create(site)), null, //$NON-NLS-1$//$NON-NLS-2$ + null); + service.registerServlet(root + "private", new BasicResourceDelivery(root + "private", URI.create(site)), //$NON-NLS-1$//$NON-NLS-2$ + null, secureHttpContext); + service.registerServlet(root + "never", new BasicResourceDelivery(root + "private", URI.create(site)), null, //$NON-NLS-1$//$NON-NLS-2$ + alwaysFail); + service.registerServlet(root + "flipFlop", new BasicResourceDelivery(root + "private", URI.create(site)), //$NON-NLS-1$//$NON-NLS-2$ + null, flipFlop); + service.registerServlet(root + "molested", new FileMolester(root + "molested", URI.create(site), 40), null, //$NON-NLS-1$//$NON-NLS-2$ + null); + service.registerServlet(root + "decelerate", //$NON-NLS-1$ + new ChopAndDelay(root + "decelerate", URI.create(site), 3, 0, new LinearChange(0, 5, 100, 0)), null, //$NON-NLS-1$ + null); + service.registerServlet(root + "decelerate2", //$NON-NLS-1$ + new ChopAndDelay(root + "decelerate2", URI.create(site), 3, 80, new LinearChange(100, 5, 105, 0)), null, //$NON-NLS-1$ + null); + service.registerServlet(root + "readtimeout", new ChopAndDelay(root + "readtimeout", URI.create(site), 3, //$NON-NLS-1$//$NON-NLS-2$ + 10, new LinearChange(10 * 60 * 1000, 5, 5 + 10 * 60 * 1000, 0)), null, null); // lie about modified time - httpService.registerServlet(root + "modified/zero", new LastModifiedLier(root + "modified/zero", URI.create(site), LastModifiedLier.TYPE_ZERO), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "modified/old", new LastModifiedLier(root + "modified/old", URI.create(site), LastModifiedLier.TYPE_OLD), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "modified/now", new LastModifiedLier(root + "modified/now", URI.create(site), LastModifiedLier.TYPE_NOW), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "modified/future", new LastModifiedLier(root + "modified/future", URI.create(site), LastModifiedLier.TYPE_FUTURE), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "modified/bad", new LastModifiedLier(root + "modified/bad", URI.create(site), LastModifiedLier.TYPE_BAD), null, null); //$NON-NLS-1$//$NON-NLS-2$ + service.registerServlet(root + "modified/zero", //$NON-NLS-1$ + new LastModifiedLier(root + "modified/zero", URI.create(site), LastModifiedLier.TYPE_ZERO), null, null); //$NON-NLS-1$ + service.registerServlet(root + "modified/old", //$NON-NLS-1$ + new LastModifiedLier(root + "modified/old", URI.create(site), LastModifiedLier.TYPE_OLD), null, null); //$NON-NLS-1$ + service.registerServlet(root + "modified/now", //$NON-NLS-1$ + new LastModifiedLier(root + "modified/now", URI.create(site), LastModifiedLier.TYPE_NOW), null, null); //$NON-NLS-1$ + service.registerServlet(root + "modified/future", //$NON-NLS-1$ + new LastModifiedLier(root + "modified/future", URI.create(site), LastModifiedLier.TYPE_FUTURE), null, //$NON-NLS-1$ + null); + service.registerServlet(root + "modified/bad", //$NON-NLS-1$ + new LastModifiedLier(root + "modified/bad", URI.create(site), LastModifiedLier.TYPE_BAD), null, null); //$NON-NLS-1$ // lie about length - httpService.registerServlet(root + "length/zero", new ContentLengthLier(root + "length/zero", URI.create(site), 0), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "length/less", new ContentLengthLier(root + "length/less", URI.create(site), 90), null, null); //$NON-NLS-1$//$NON-NLS-2$ - httpService.registerServlet(root + "length/more", new ContentLengthLier(root + "length/more", URI.create(site), 200), null, null); //$NON-NLS-1$//$NON-NLS-2$ + service.registerServlet(root + "length/zero", //$NON-NLS-1$ + new ContentLengthLier(root + "length/zero", URI.create(site), 0), null, null); //$NON-NLS-1$ + service.registerServlet(root + "length/less", //$NON-NLS-1$ + new ContentLengthLier(root + "length/less", URI.create(site), 90), null, null); //$NON-NLS-1$ + service.registerServlet(root + "length/more", //$NON-NLS-1$ + new ContentLengthLier(root + "length/more", URI.create(site), 200), null, null); //$NON-NLS-1$ } @@ -141,15 +176,16 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer { return httpService; } - public void modifiedService(ServiceReference reference, Object service) { - // do nothing + @Override + public void modifiedService(ServiceReference<HttpService> reference, HttpService service) { + // do nothing } - public void removedService(ServiceReference reference, Object service) { - httpService = (HttpService) service; - httpService.unregister("/public"); //$NON-NLS-1$ - httpService.unregister("/private"); //$NON-NLS-1$ - httpService.unregister("/stats"); //$NON-NLS-1$ + @Override + public void removedService(ServiceReference<HttpService> reference, HttpService service) { + service.unregister("/public"); //$NON-NLS-1$ + service.unregister("/private"); //$NON-NLS-1$ + service.unregister("/stats"); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/AlwaysFailContext.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/AlwaysFailContext.java index 6d4711897..6fa5a1674 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/AlwaysFailContext.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/AlwaysFailContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,16 +17,17 @@ import javax.servlet.http.HttpServletResponse; import org.osgi.service.http.HttpContext; /** - * The AlwaysFailContext can be used to add basic authentication to a path. - * This implementation will always fail (easier to test failure logic) this way. + * The AlwaysFailContext can be used to add basic authentication to a path. This + * implementation will always fail (easier to test failure logic) this way. */ public class AlwaysFailContext implements HttpContext { - private HttpContext theDefaultContext; + private final HttpContext theDefaultContext; public AlwaysFailContext(HttpContext defaultContext) { theDefaultContext = defaultContext; } + @Override public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) { // always fail response.setHeader("WWW-Authenticate", "BASIC realm=\"p2 Http Testing Server (Aladdin, open sesame)\""); //$NON-NLS-1$//$NON-NLS-2$ @@ -35,10 +36,12 @@ public class AlwaysFailContext implements HttpContext { } + @Override public String getMimeType(String name) { return theDefaultContext.getMimeType(name); } + @Override public URL getResource(String name) { return theDefaultContext.getResource(name); } diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/FlipFlopFailContext.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/FlipFlopFailContext.java index 2ac9e7d04..4d9f0acba 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/FlipFlopFailContext.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/FlipFlopFailContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,18 +17,20 @@ import javax.servlet.http.HttpServletResponse; import org.osgi.service.http.HttpContext; /** - * The SecureContext can be used to add basic authentication to a path. - * It will fail on every other request to enable flaky server, or authentication testing. - * This implementation requires the user "Aladdin" to log in with the password "open sesame". + * The SecureContext can be used to add basic authentication to a path. It will + * fail on every other request to enable flaky server, or authentication + * testing. This implementation requires the user "Aladdin" to log in with the + * password "open sesame". */ public class FlipFlopFailContext implements HttpContext { - private HttpContext theDefaultContext; + private final HttpContext theDefaultContext; public static int flipFlop = 0; public FlipFlopFailContext(HttpContext defaultContext) { theDefaultContext = defaultContext; } + @Override public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) { String auth = request.getHeader("Authorization"); //$NON-NLS-1$ // Response is Aladdin:open sesame in Base64 encoding (from RFC example) @@ -42,10 +44,12 @@ public class FlipFlopFailContext implements HttpContext { } + @Override public String getMimeType(String name) { return theDefaultContext.getMimeType(name); } + @Override public URL getResource(String name) { return theDefaultContext.getResource(name); } diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/MimeLookup.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/MimeLookup.java index 71c09f80d..742ed299d 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/MimeLookup.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/MimeLookup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,22 +23,23 @@ public class MimeLookup { // treat names with multiple "." in a special way (currently only one) if (name.endsWith(JAR_PACK_GZ)) - return (String) extMap.get(JAR_PACK_GZ); + return extMap.get(JAR_PACK_GZ); int dot = name.lastIndexOf("."); //$NON-NLS-1$ - // get the suffix, use "a" for empty as this gives the default "application/octet-stream" + // get the suffix, use "a" for empty as this gives the default + // "application/octet-stream" String tmp = dot == -1 ? "a" : name.substring(dot + 1); //$NON-NLS-1$ - tmp = (String) extMap.get(tmp); + tmp = extMap.get(tmp); return tmp == null ? "application/octet-stream" : tmp; //$NON-NLS-1$ } - private static Map extMap; - private static Map mimeMap; + private static Map<String, String> extMap; + private static Map<String, String> mimeMap; public static void initNameToMime() { - extMap = new HashMap(data.length); + extMap = new HashMap<>(data.length); for (int i = 0; i < data.length; i += 2) { - Object key = data[i]; - Object val = extMap.get(key); + String key = data[i]; + String val = extMap.get(key); if (val == null) extMap.put(key, data[i]); } @@ -46,10 +47,10 @@ public class MimeLookup { } public static void initMimeToExt() { - mimeMap = new HashMap(data.length); + mimeMap = new HashMap<>(data.length); for (int i = 0; i < data.length; i += 2) { - Object key = data[i + 1]; - Object val = mimeMap.get(key); + String key = data[i + 1]; + String val = mimeMap.get(key); if (val == null) mimeMap.put(key, data[i]); } @@ -57,7 +58,7 @@ public class MimeLookup { } public final static String[] data = { // - //--- typical java related mime types - higher priority + // --- typical java related mime types - higher priority "bat", "text/plain", //$NON-NLS-1$ //$NON-NLS-2$ "batfrag", "text/plain", //$NON-NLS-1$ //$NON-NLS-2$ "class", "application/octet-stream", //$NON-NLS-1$ //$NON-NLS-2$ @@ -89,7 +90,7 @@ public class MimeLookup { "xmlfrag", "text/plain", //$NON-NLS-1$ //$NON-NLS-2$ "zip", "application/zip", //$NON-NLS-1$ //$NON-NLS-2$ - //--- misc definitions + // --- misc definitions "3dm", "x-world/x-3dmf", //$NON-NLS-1$ //$NON-NLS-2$ "3dmf", "x-world/x-3dmf", //$NON-NLS-1$ //$NON-NLS-2$ @@ -106,7 +107,7 @@ public class MimeLookup { "aifc", "audio/aiff", //$NON-NLS-1$ //$NON-NLS-2$ "aifc", "audio/x-aiff", //$NON-NLS-1$ //$NON-NLS-2$ "aiff", "audio/aiff", //$NON-NLS-1$ //$NON-NLS-2$ - "aiff", "audio/x-aiff", //$NON-NLS-1$ //$NON-NLS-2$ + "aiff", "audio/x-aiff", //$NON-NLS-1$ //$NON-NLS-2$ "aim", "application/x-aim", //$NON-NLS-1$ //$NON-NLS-2$ "aip", "text/x-audiosoft-intra", //$NON-NLS-1$ //$NON-NLS-2$ "ani", "application/x-navi-animation", //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureAction.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureAction.java index 483257843..2837d9ddd 100755 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureAction.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureAction.java @@ -26,11 +26,11 @@ import org.osgi.framework.Bundle; */ public class SecureAction { // make sure we use the correct controlContext; - private AccessControlContext controlContext; + private final AccessControlContext controlContext; /** - * Constructs a new SecureAction object. The constructed SecureAction object - * uses the caller's AccessControlContext to perform security checks + * Constructs a new SecureAction object. The constructed SecureAction object + * uses the caller's AccessControlContext to perform security checks */ public SecureAction() { // save the control context to be used. @@ -39,58 +39,48 @@ public class SecureAction { /** * Gets a resource from a bundle. + * * @param bundle the bundle to get the resource from - * @param name The name of the resource + * @param name The name of the resource * @return The URL of the resource */ - + public URL getBundleResource(final Bundle bundle, final String name) { if (System.getSecurityManager() == null) - return bundle.getResource(name); - return (URL) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return bundle.getResource(name); - } - }, controlContext); + return bundle.getResource(name); + return AccessController.doPrivileged((PrivilegedAction<URL>) () -> bundle.getResource(name), controlContext); } - + public URLConnection openURL(final URL url) throws IOException { if (System.getSecurityManager() == null) - return open(url); - try { - return (URLConnection) AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IOException { - return open(url); - } - }, controlContext); - } catch(PrivilegedActionException ex) { + return open(url); + try { + return AccessController.doPrivileged((PrivilegedExceptionAction<URLConnection>) () -> open(url), + controlContext); + } catch (PrivilegedActionException ex) { throw (IOException) ex.getException(); } - } - - URLConnection open(final URL url)throws IOException - { + } + + URLConnection open(final URL url) throws IOException { URLConnection connection = url.openConnection(); - connection.connect(); /* establish connection to check permissions */ - return connection; + connection.connect(); /* establish connection to check permissions */ + return connection; } - + /** - * Returns a system property. Same as calling - * System.getProperty(String,String). + * Returns a system property. Same as calling System.getProperty(String,String). + * * @param property the property key. - * @param def the default value if the property key does not exist. - * @return the value of the property or the def value if the property - * does not exist. + * @param def the default value if the property key does not exist. + * @return the value of the property or the def value if the property does not + * exist. */ public String getProperty(final String property, final String def) { if (System.getSecurityManager() == null) return System.getProperty(property, def); - return (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(property, def); - } - }, controlContext); + return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property, def), + controlContext); } } diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureContext.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureContext.java index a9fc4e5f4..d4f295c0d 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureContext.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecureContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,16 +17,18 @@ import javax.servlet.http.HttpServletResponse; import org.osgi.service.http.HttpContext; /** - * The SecureContext can be used to add basic authentication to a path. - * This implementation requires the user "Aladdin" to log in with the password "open sesame". + * The SecureContext can be used to add basic authentication to a path. This + * implementation requires the user "Aladdin" to log in with the password "open + * sesame". */ public class SecureContext implements HttpContext { - private HttpContext theDefaultContext; + private final HttpContext theDefaultContext; public SecureContext(HttpContext defaultContext) { theDefaultContext = defaultContext; } + @Override public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) { String auth = request.getHeader("Authorization"); //$NON-NLS-1$ // Response is Aladdin:open sesame in Base64 encoding (from RFC example) @@ -40,10 +42,12 @@ public class SecureContext implements HttpContext { } + @Override public String getMimeType(String name) { return theDefaultContext.getMimeType(name); } + @Override public URL getResource(String name) { return theDefaultContext.getResource(name); } diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java index 4b627f6eb..9d66da4e9 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/SecuredArtifactsContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,8 +16,9 @@ import javax.servlet.http.HttpServletResponse; import org.osgi.service.http.HttpContext; /** - * The SecureContext can be used to add basic authentication to a path. - * This implementation requires the user "Aladdin" to log in with the password "open sesame". + * The SecureContext can be used to add basic authentication to a path. This + * implementation requires the user "Aladdin" to log in with the password "open + * sesame". */ public class SecuredArtifactsContext extends SecureContext { @@ -25,6 +26,7 @@ public class SecuredArtifactsContext extends SecureContext { super(defaultContext); } + @Override public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) { String path = request.getRequestURI(); if (path == null) diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java index 13dc0cf99..7afe05a15 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,9 +39,9 @@ import org.osgi.service.http.HttpService; public class BasicResourceDelivery extends HttpServlet { private static final long serialVersionUID = 1L; // private static final String CHARSET = "utf-8"; //$NON-NLS-1$ - private SecureAction secureAction; - private String alias; - private URI path; + private final SecureAction secureAction; + private final String alias; + private final URI path; protected static final String defaultMimeType = "application/octet-stream"; //$NON-NLS-1$ /** @@ -53,6 +53,7 @@ public class BasicResourceDelivery extends HttpServlet { path = thePath; } + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { URI resource = null; try { @@ -70,7 +71,7 @@ public class BasicResourceDelivery extends HttpServlet { } if (url == null) { - fileNotFound(resource, request, response); + fileNotFound(resource, response); return; } @@ -89,7 +90,7 @@ public class BasicResourceDelivery extends HttpServlet { try { in = conn.getInputStream(); } catch (IOException ex) { - fileNotFound(resource, request, response); + fileNotFound(resource, response); return; } try { @@ -101,23 +102,26 @@ public class BasicResourceDelivery extends HttpServlet { } } - protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, + HttpServletResponse response) throws IOException { this.doDeliver(conn, in, filename, request, response); } - /** - * Default method delivering content from a file. Subclasses should override this method - * to deliver "broken content" (e.g. truncated, mismatched content length etc.). - * This default method performs the same delivery as the default "register resource" in the - * http service. - * @param conn - The URLConnection to the resource - * @param in - InputStream to read from + /** + * Default method delivering content from a file. Subclasses should override + * this method to deliver "broken content" (e.g. truncated, mismatched content + * length etc.). This default method performs the same delivery as the default + * "register resource" in the http service. + * + * @param conn - The URLConnection to the resource + * @param in - InputStream to read from * @param filename - the filename being read - * @param request - the servlet request + * @param request - the servlet request * @param response - the servlet response * @throws IOException - on errors */ - protected void doDeliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + protected void doDeliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, + HttpServletResponse response) throws IOException { // set when the resource was modified addDateHeader(response, HttpConstants.LAST_MODIFIED, getLastModified(conn)); int statusCode = HttpHeaderToStatus(conn.getHeaderField(0)); @@ -160,11 +164,14 @@ public class BasicResourceDelivery extends HttpServlet { } } - protected void fileNotFound(URI file, HttpServletRequest request, HttpServletResponse response) throws IOException { - response.sendError(HttpServletResponse.SC_NOT_FOUND, (file == null ? "<no file>" : file.toString()) + " not found"); //$NON-NLS-1$ //$NON-NLS-2$ + protected void fileNotFound(URI file, HttpServletResponse response) throws IOException { + response.sendError(HttpServletResponse.SC_NOT_FOUND, + (file == null ? "<no file>" : file.toString()) + " not found"); //$NON-NLS-1$ //$NON-NLS-2$ } - protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + @Override + protected void doHead(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { URI resource = null; try { resource = getFilename(request.getRequestURI()); @@ -181,7 +188,7 @@ public class BasicResourceDelivery extends HttpServlet { } if (url == null) { - fileNotFound(resource, request, response); + fileNotFound(resource, response); return; } URLConnection conn = secureAction.openURL(url); @@ -190,11 +197,13 @@ public class BasicResourceDelivery extends HttpServlet { doDeliverHead(resource.toString(), conn, request, response); // TODO: change API to use URI? } - protected void deliverHead(String filename, URLConnection conn, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void deliverHead(String filename, URLConnection conn, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { this.doDeliverHead(filename, conn, request, response); } - protected void doDeliverHead(String filename, URLConnection conn, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doDeliverHead(String filename, URLConnection conn, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { int contentlength = getContentLength(conn); int statusCode = HttpHeaderToStatus(conn.getHeaderField(0)); // set status = ok if there was no http header... @@ -226,6 +235,7 @@ public class BasicResourceDelivery extends HttpServlet { /** * Override to lie about last modified + * * @param conn * @return time in ms */ @@ -235,6 +245,7 @@ public class BasicResourceDelivery extends HttpServlet { /** * Override to lie about content length + * * @param conn * @return length in bytes */ @@ -243,14 +254,16 @@ public class BasicResourceDelivery extends HttpServlet { } protected URI getFilename(String filename) throws URISyntaxException { - //If the requested URI is equal to the Registeration's alias, send the file - //corresponding to the alias. Otherwise, we have request for a file in an - //registered directory (the file was not directly registered itself). + // If the requested URI is equal to the Registeration's alias, send the file + // corresponding to the alias. Otherwise, we have request for a file in an + // registered directory (the file was not directly registered itself). if (filename.equals(alias)) { filename = path.getPath(); } else { - // The file we re looking for is the registered resource (alias) + the rest of the - // filename that is not part of the registered resource. For example, if we export + // The file we re looking for is the registered resource (alias) + the rest of + // the + // filename that is not part of the registered resource. For example, if we + // export // /a to /tmp and we have a request for /a/b/foo.txt, then /tmp is our directory // (file.toString()) and /b/foo.txt is the rest. // The result is that we open the file /tmp/b/foo.txt. @@ -280,14 +293,15 @@ public class BasicResourceDelivery extends HttpServlet { filename = buf.toString(); } } - return new URI(path.getScheme(), path.getUserInfo(), path.getHost(), path.getPort(), filename, path.getQuery(), path.getFragment()); + return new URI(path.getScheme(), path.getUserInfo(), path.getHost(), path.getPort(), filename, path.getQuery(), + path.getFragment()); // return (filename); } /** * This method returns the correct MIME type of a given URI by first checking - * the HttpContext::getMimeType and, if null, checking the httpservice's MIMETypes table. - * return mimetype with charset=utf-8 for all text/... types + * the HttpContext::getMimeType and, if null, checking the httpservice's + * MIMETypes table. return mimetype with charset=utf-8 for all text/... types */ protected String computeMimeType(String name, URLConnection conn) { String mimeType = computeMimeType2(name, conn); @@ -318,7 +332,9 @@ public class BasicResourceDelivery extends HttpServlet { public static final DateFormat PATTERN_RFC1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); //$NON-NLS-1$ /** - * Support setting date header - in servlet > 2.1 it is possible to call this method directly on the HttpResponse. + * Support setting date header - in servlet > 2.1 it is possible to call this + * method directly on the HttpResponse. + * * @param response * @param name * @param timestamp diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ChopAndDelay.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ChopAndDelay.java index c8e823c8f..4be451bad 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ChopAndDelay.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ChopAndDelay.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,29 +24,31 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.equinox.p2.testserver.LinearChange; /** - * The ChopAndDelay deliver the content chopped up in smaller packets and adds delay - * between packets. - * + * The ChopAndDelay deliver the content chopped up in smaller packets and adds + * delay between packets. + * */ public class ChopAndDelay extends BasicResourceDelivery { int chopFactor; private LinearChange delayFunction; private long msDelay; - private int fastPercent; + private final int fastPercent; /** * Create a file molester that turns content into gibberish. - * - * @param theAlias the path this servlet is registered under - * @param thePath the path to use as root for the alias - * @param chopFactor - a value between 1 and 12 where 1 is one byte, and 12 is 4k bytes at a time. + * + * @param theAlias the path this servlet is registered under + * @param thePath the path to use as root for the alias + * @param chopFactor - a value between 1 and 12 where 1 is one byte, and 12 + * is 4k bytes at a time. * @param delayFunction - function returning a series of delay values */ public ChopAndDelay(String theAlias, URI thePath, int chopFactor, int fastPercent, LinearChange delayFunction) { super(theAlias, thePath); if (chopFactor < 1 || chopFactor > 12) - throw new IllegalArgumentException("chopFactor must be between 1 and 12 (inclusive) - was:" + Integer.valueOf(chopFactor)); //$NON-NLS-1$ + throw new IllegalArgumentException( + "chopFactor must be between 1 and 12 (inclusive) - was:" + Integer.valueOf(chopFactor)); //$NON-NLS-1$ this.chopFactor = chopFactor; if (fastPercent < 0 || fastPercent > 100) throw new IllegalArgumentException("fastPercent must be 0-100 - was:" + Integer.valueOf(fastPercent)); //$NON-NLS-1$ @@ -60,12 +62,15 @@ public class ChopAndDelay extends BasicResourceDelivery { private static final long serialVersionUID = 1L; - protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + @Override + protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, + HttpServletResponse response) throws IOException { // chop up all files - doChop(conn, in, filename, request, response); + doChop(conn, in, filename, response); } - protected void doChop(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + protected void doChop(URLConnection conn, InputStream in, String filename, HttpServletResponse response) + throws IOException { LinearChange delayer = delayFunction.fork(); int contentlength = conn.getContentLength(); if (contentlength >= 0) { diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ContentLengthLier.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ContentLengthLier.java index 98a037736..532e5b549 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ContentLengthLier.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/ContentLengthLier.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,9 +19,10 @@ public class ContentLengthLier extends BasicResourceDelivery { double keepFactor; /** - * The ContentLengthLier sets the content length to a percentage of the original length. - * Values between 0 and 200 can be used (to lie about files being both smaller < 100, or larger > 100). - * + * The ContentLengthLier sets the content length to a percentage of the original + * length. Values between 0 and 200 can be used (to lie about files being both + * smaller < 100, or larger > 100). + * * @param theAlias * @param thePath * @param keepPercent - how much to lie between 0 and 200 (inclusive) @@ -29,12 +30,14 @@ public class ContentLengthLier extends BasicResourceDelivery { public ContentLengthLier(String theAlias, URI thePath, int keepPercent) { super(theAlias, thePath); if (keepPercent < 0 || keepPercent > 200) - throw new IllegalArgumentException("keepPercent must be between 0 and 200 - was:" + Integer.valueOf(keepPercent)); //$NON-NLS-1$ + throw new IllegalArgumentException( + "keepPercent must be between 0 and 200 - was:" + Integer.valueOf(keepPercent)); //$NON-NLS-1$ keepFactor = keepPercent / 100.0; } private static final long serialVersionUID = 1L; + @Override protected int getContentLength(URLConnection conn) { int contentLength = conn.getContentLength(); return (contentLength >= 0) ? (int) (contentLength * keepFactor) : contentLength; diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/FileMolester.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/FileMolester.java index 3a5485230..14b74cc83 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/FileMolester.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/FileMolester.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,11 +23,12 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * The FileMolester will keep a certain amount of the file from the beginning, and return - * garbage/gibberish for the rest of the file's content. The garbage is produced by shifting every - * byte 1 bit to the left. - * - * The idea for keeping some percentage is to support keeping xml headers / doctype etc. + * The FileMolester will keep a certain amount of the file from the beginning, + * and return garbage/gibberish for the rest of the file's content. The garbage + * is produced by shifting every byte 1 bit to the left. + * + * The idea for keeping some percentage is to support keeping xml headers / + * doctype etc. */ public class FileMolester extends BasicResourceDelivery { @@ -35,9 +36,9 @@ public class FileMolester extends BasicResourceDelivery { /** * Create a file molester that turns content into gibberish. - * - * @param theAlias the path this servlet is registered under - * @param thePath the path to use as root for the alias + * + * @param theAlias the path this servlet is registered under + * @param thePath the path to use as root for the alias * @param keepLength - how many bytes in the beginning that will be unmolested */ public FileMolester(String theAlias, URI thePath, int keepLength) { @@ -49,12 +50,15 @@ public class FileMolester extends BasicResourceDelivery { private static final long serialVersionUID = 1L; - protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + @Override + protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, + HttpServletResponse response) throws IOException { // molest all files - doMolest(conn, in, filename, request, response); + doMolest(conn, in, filename, response); } - protected void doMolest(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + protected void doMolest(URLConnection conn, InputStream in, String filename, HttpServletResponse response) + throws IOException { int contentlength = conn.getContentLength(); if (contentlength >= 0) { response.setContentLength(contentlength); diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/HelloWorld.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/HelloWorld.java index 7bc682803..e50a30806 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/HelloWorld.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/HelloWorld.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,13 +18,14 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * Simple "smoke test" servlet - for manual testing that the http server is running and is - * capable of running servlets. + * Simple "smoke test" servlet - for manual testing that the http server is + * running and is capable of running servlets. */ public class HelloWorld extends HttpServlet { private static final long serialVersionUID = 1L; + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); //$NON-NLS-1$ PrintWriter writer = response.getWriter(); diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java index ac17e7ad5..f4060f8be 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java @@ -15,7 +15,7 @@ import org.eclipse.equinox.p2.testserver.HttpConstants; public class IntermittentTimeout extends BasicResourceDelivery { /** - * + * */ private static final long serialVersionUID = 2216234319571297257L; int count = 1; @@ -24,7 +24,9 @@ public class IntermittentTimeout extends BasicResourceDelivery { super(theAlias, thePath); } - protected void doDeliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + @Override + protected void doDeliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, + HttpServletResponse response) throws IOException { // set when the resource was modified addDateHeader(response, HttpConstants.LAST_MODIFIED, getLastModified(conn)); int statusCode = HttpHeaderToStatus(conn.getHeaderField(0)); diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java index 84d568ca1..74a95a5e8 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,12 +16,13 @@ import java.net.URLConnection; import javax.servlet.http.HttpServletResponse; /** - * Manipulates the last modified time of serviced files. - * The manipulator will set all modified times to 0 if TYPE_ZERO is used, to 1 if TYPE_OLD is used, - * to the current time if TYPE_NOW is used, and a value 24 hours into the future if TYPE_FUTURE is used. - * (Future values are not allowed in HTTP - the server should guard against them and force the value - * to be no bigger than the response date). - * The TYPE_BAD will produce a HTTP header with wrong format for the date value (fails date parsing). + * Manipulates the last modified time of serviced files. The manipulator will + * set all modified times to 0 if TYPE_ZERO is used, to 1 if TYPE_OLD is used, + * to the current time if TYPE_NOW is used, and a value 24 hours into the future + * if TYPE_FUTURE is used. (Future values are not allowed in HTTP - the server + * should guard against them and force the value to be no bigger than the + * response date). The TYPE_BAD will produce a HTTP header with wrong format for + * the date value (fails date parsing). * */ public class LastModifiedLier extends BasicResourceDelivery { @@ -33,12 +34,12 @@ public class LastModifiedLier extends BasicResourceDelivery { public static final int TYPE_BAD = 5; private static final int TYPE_LAST = TYPE_BAD; - private int type; + private final int type; /** - * The LastModifiedLier returns a last modified time according to the parameter timeType. - * It can be TYPE_ZERO, TYPE_OLD, TYPE_NOW, TYPE_FUTURE, or TYPE_BAD. - * + * The LastModifiedLier returns a last modified time according to the parameter + * timeType. It can be TYPE_ZERO, TYPE_OLD, TYPE_NOW, TYPE_FUTURE, or TYPE_BAD. + * * @param theAlias * @param thePath * @param timeType - a TYPE_XXX constant defining what time to return @@ -52,6 +53,7 @@ public class LastModifiedLier extends BasicResourceDelivery { private static final long serialVersionUID = 1L; + @Override protected long getLastModified(URLConnection conn) { // ignore real value and lie based on constant return getLastModified(); @@ -59,19 +61,20 @@ public class LastModifiedLier extends BasicResourceDelivery { private long getLastModified() { switch (type) { - case TYPE_ZERO : - return 0L; - case TYPE_OLD : - return 1000L; - case TYPE_NOW : - return System.currentTimeMillis(); - case TYPE_FUTURE : - return System.currentTimeMillis() + 24 * 60 * 60 * 1000; + case TYPE_ZERO: + return 0L; + case TYPE_OLD: + return 1000L; + case TYPE_NOW: + return System.currentTimeMillis(); + case TYPE_FUTURE: + return System.currentTimeMillis() + 24 * 60 * 60 * 1000; } // should not happen return 0L; } + @Override public void addDateHeader(HttpServletResponse response, String name, long timestamp) { if (type != TYPE_BAD) super.addDateHeader(response, name, timestamp); diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Redirector.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Redirector.java index ab875afb0..c61ce7ebf 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Redirector.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Redirector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,13 +20,15 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * Redirects n times, before redirecting to final location (a path on same server). - * + * Redirects n times, before redirecting to final location (a path on same + * server). + * */ public class Redirector extends HttpServlet { private static final long serialVersionUID = 1L; + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); //$NON-NLS-1$ PrintWriter writer = response.getWriter(); @@ -38,7 +40,9 @@ public class Redirector extends HttpServlet { String[] result = requestPath.split("/"); //$NON-NLS-1$ if (result.length < 3 && !"redirect".equalsIgnoreCase(result[1])) //$NON-NLS-1$ { - getServletContext().log("Error Servlet requires being configured to get /redirect/count paths. Example /redirect/500, got" + requestPath); //$NON-NLS-1$ + getServletContext().log( + "Error Servlet requires being configured to get /redirect/count paths. Example /redirect/500, got" //$NON-NLS-1$ + + requestPath); return; } // get the error code @@ -85,6 +89,7 @@ public class Redirector extends HttpServlet { } } + @Override public void doHead(HttpServletRequest request, HttpServletResponse response) { // produce same response as for GET, but no content (writer == null) doStatus(request, response, null); diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Stats.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Stats.java index a9123506a..8039abdac 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Stats.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Stats.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2016 Wind River and others. + * Copyright (c) 2012, 2018 Wind River and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,11 +18,9 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.TimeZone; -import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -30,18 +28,16 @@ import org.eclipse.equinox.p2.testserver.HttpConstants; public class Stats extends HttpServlet { - /** - * - */ private static final long serialVersionUID = -3209768955270841029L; private static final String UnkownPackage = "unkown"; //$NON-NLS-1$ private static final String PACKAGE = "package"; //$NON-NLS-1$ - private Map downloadStats = new HashMap(); + private final Map<String, Integer> downloadStats = new HashMap<>(); public Stats() { downloadStats.put(UnkownPackage, Integer.valueOf(0)); } + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { responseHeaderAndStatus(response); @@ -75,15 +71,17 @@ public class Stats extends HttpServlet { private String getStatsResult() { StringBuffer sb = new StringBuffer(); - sb.append("It's a page to count the downloading times when heading this page with query 'package=<package name>'.\n"); //$NON-NLS-1$ - for (Iterator iter = downloadStats.keySet().iterator(); iter.hasNext();) { - String packageName = (String) iter.next(); + sb.append( + "It's a page to count the downloading times when heading this page with query 'package=<package name>'.\n"); //$NON-NLS-1$ + for (String string : downloadStats.keySet()) { + String packageName = string; sb.append(packageName).append(" download number: ").append(downloadStats.get(packageName)).append("\n"); //$NON-NLS-1$//$NON-NLS-2$ } return sb.toString(); } - protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + @Override + protected void doHead(HttpServletRequest request, HttpServletResponse response) { String queryString = request.getQueryString(); responseHeaderAndStatus(response); @@ -91,11 +89,11 @@ public class Stats extends HttpServlet { boolean found = false; if (queryString != null) { String[] parameters = queryString.split("&"); //$NON-NLS-1$ - for (int i = 0; i < parameters.length; i++) { - String[] paraPair = parameters[i].split("=", 2); //$NON-NLS-1$ + for (String parameter : parameters) { + String[] paraPair = parameter.split("=", 2); //$NON-NLS-1$ if (paraPair.length == 2 && PACKAGE.equals(paraPair[0])) { found = true; - Integer count = (Integer) downloadStats.get(paraPair[1]); + Integer count = downloadStats.get(paraPair[1]); if (count == null) { count = Integer.valueOf(1); } else @@ -106,7 +104,7 @@ public class Stats extends HttpServlet { } } if (!found) { - Integer count = (Integer) downloadStats.get(UnkownPackage); + Integer count = downloadStats.get(UnkownPackage); downloadStats.put(UnkownPackage, Integer.valueOf(1 + count.intValue())); } } diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/StatusCodeResponse.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/StatusCodeResponse.java index d162dcd75..557e53841 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/StatusCodeResponse.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/StatusCodeResponse.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,18 +18,19 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * Produces a response with a status code specified in the request URI. - * Requires to be registered for "/status" path. The request is made on the format - * "/status/code/" where code is the HTTP integer status code. The path after /code/ can be - * anything - it is always ignored. - * The response to GET produces HTML text "Requested status: code". - * The response to HEAD just produces the status header response. - * + * Produces a response with a status code specified in the request URI. Requires + * to be registered for "/status" path. The request is made on the format + * "/status/code/" where code is the HTTP integer status code. The path after + * /code/ can be anything - it is always ignored. The response to GET produces + * HTML text "Requested status: code". The response to HEAD just produces the + * status header response. + * */ public class StatusCodeResponse extends HttpServlet { private static final long serialVersionUID = 1L; + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); //$NON-NLS-1$ PrintWriter writer = response.getWriter(); @@ -41,7 +42,9 @@ public class StatusCodeResponse extends HttpServlet { String[] result = requestPath.split("/"); //$NON-NLS-1$ if (result.length < 3 && !"status".equalsIgnoreCase(result[1])) //$NON-NLS-1$ { - getServletContext().log("Error Servlet requires being configured to get /status/statuscode paths. Example /status/500, got" + requestPath); //$NON-NLS-1$ + getServletContext().log( + "Error Servlet requires being configured to get /status/statuscode paths. Example /status/500, got" //$NON-NLS-1$ + + requestPath); return; } // get the error code @@ -60,6 +63,7 @@ public class StatusCodeResponse extends HttpServlet { htmlPage(writer, "Requested Status: " + Integer.valueOf(errorCode), false); //$NON-NLS-1$ } + @Override public void doHead(HttpServletRequest request, HttpServletResponse response) { // produce same reponse as for GET, but no content (writer == null) doStatus(request, response, null); diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/TimeOut.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/TimeOut.java index e5544cd91..5bbf3df04 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/TimeOut.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/TimeOut.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ public class TimeOut extends HttpServlet { private static final long serialVersionUID = 1L; private static long MINUTES_MS = 1000 * 60; // minutes in ms + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) { doDelay(); } @@ -37,6 +38,7 @@ public class TimeOut extends HttpServlet { } } + @Override protected void doHead(HttpServletRequest request, HttpServletResponse response) { doDelay(); } diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Truncator.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Truncator.java index 17c4bf636..35804b2ab 100644 --- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Truncator.java +++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/Truncator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, Cloudsmith Inc and others. + * Copyright (c) 2009, 2018 Cloudsmith Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,18 +30,22 @@ public class Truncator extends BasicResourceDelivery { public Truncator(String theAlias, URI thePath, int keepPercent) { super(theAlias, thePath); if (keepPercent < 0 || keepPercent > 100) - throw new IllegalArgumentException("keepPercent must be between 0 and 100 - was:" + Integer.valueOf(keepPercent)); //$NON-NLS-1$ + throw new IllegalArgumentException( + "keepPercent must be between 0 and 100 - was:" + Integer.valueOf(keepPercent)); //$NON-NLS-1$ keepFactor = keepPercent / 100.0; } private static final long serialVersionUID = 1L; - protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + @Override + protected void deliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, + HttpServletResponse response) throws IOException { // truncate all files - doTruncate(conn, in, filename, request, response); + doTruncate(conn, in, filename, response); } - protected void doTruncate(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + protected void doTruncate(URLConnection conn, InputStream in, String filename, HttpServletResponse response) + throws IOException { int contentlength = conn.getContentLength(); if (contentlength >= 0) { response.setContentLength(contentlength); @@ -86,6 +90,7 @@ public class Truncator extends BasicResourceDelivery { /** * Returns read if entire amount should be read. Returns a lower number if * written + read > keepPercent of total + * * @param total * @param written * @param read @@ -96,7 +101,9 @@ public class Truncator extends BasicResourceDelivery { return (read + written) > cap ? cap - written : read; } - protected void deliverHead(String filename, URLConnection conn, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + @Override + protected void deliverHead(String filename, URLConnection conn, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { // deliver normal head response super.doDeliverHead(filename, conn, request, response); |