Skip to content

Commit ef712db

Browse files
committed
remove deprecated code
1 parent 7d40e6a commit ef712db

File tree

7 files changed

+4
-151
lines changed

7 files changed

+4
-151
lines changed

powertools-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/Response.java

-34
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,6 @@ public static Builder builder() {
4747
return new Builder();
4848
}
4949

50-
/**
51-
* Creates a failed Response with no physicalResourceId set. Powertools for AWS Lambda (Java) will set the physicalResourceId to the
52-
* Lambda LogStreamName
53-
* <p>
54-
* The value returned for a PhysicalResourceId can change custom resource update operations. If the value returned
55-
* is the same, it is considered a normal update. If the value returned is different, AWS CloudFormation recognizes
56-
* the update as a replacement and sends a delete request to the old resource. For more information,
57-
* see AWS::CloudFormation::CustomResource.
58-
*
59-
* @return a failed Response with no value.
60-
* @deprecated this method is not safe. Provide a physicalResourceId.
61-
*/
62-
@Deprecated
63-
public static Response failed() {
64-
return new Response(null, Status.FAILED, null, false);
65-
}
66-
6750
/**
6851
* Creates a failed Response with a given physicalResourceId.
6952
*
@@ -80,23 +63,6 @@ public static Response failed(String physicalResourceId) {
8063
return new Response(null, Status.FAILED, physicalResourceId, false);
8164
}
8265

83-
/**
84-
* Creates a successful Response with no physicalResourceId set. Powertools for AWS Lambda (Java) will set the physicalResourceId to the
85-
* Lambda LogStreamName
86-
* <p>
87-
* The value returned for a PhysicalResourceId can change custom resource update operations. If the value returned
88-
* is the same, it is considered a normal update. If the value returned is different, AWS CloudFormation recognizes
89-
* the update as a replacement and sends a delete request to the old resource. For more information,
90-
* see AWS::CloudFormation::CustomResource.
91-
*
92-
* @return a success Response with no physicalResourceId value.
93-
* @deprecated this method is not safe. Provide a physicalResourceId.
94-
*/
95-
@Deprecated
96-
public static Response success() {
97-
return new Response(null, Status.SUCCESS, null, false);
98-
}
99-
10066
/**
10167
* Creates a successful Response with a given physicalResourceId.
10268
*

powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java

-31
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,6 @@ public static void defaultDimensions(final DimensionSet... dimensionSets) {
6363
MetricsUtils.defaultDimensions = dimensionSets;
6464
}
6565

66-
/**
67-
* Configure default dimension to be used by logger.
68-
* By default, @{@link Metrics} annotation captures configured service as a dimension <i>Service</i>
69-
*
70-
* @param dimensionSet Default value of dimension set for logger
71-
* @deprecated use {@link #defaultDimensions(DimensionSet...)} instead
72-
*/
73-
@Deprecated
74-
public static void defaultDimensionSet(final DimensionSet dimensionSet) {
75-
requireNonNull(dimensionSet, "Null dimension set not allowed");
76-
77-
if (dimensionSet.getDimensionKeys().size() > 0) {
78-
defaultDimensions(dimensionSet);
79-
}
80-
}
81-
82-
8366
/**
8467
* Add and immediately flush a single metric. It will use the default namespace
8568
* specified either on {@link Metrics} annotation or via POWERTOOLS_METRICS_NAMESPACE env var.
@@ -146,20 +129,6 @@ public static void withMetricsLogger(final Consumer<MetricsLogger> logger) {
146129
}
147130
}
148131

149-
/**
150-
* Provide and immediately flush a {@link MetricsLogger}. It uses the default namespace
151-
* specified either on {@link Metrics} annotation or via POWERTOOLS_METRICS_NAMESPACE env var.
152-
* It by default captures function_request_id as property if used together with {@link Metrics} annotation. It will also
153-
* capture xray_trace_id as property if tracing is enabled.
154-
*
155-
* @param logger the MetricsLogger
156-
* @deprecated use {@link MetricsUtils#withMetricsLogger} instead
157-
*/
158-
@Deprecated
159-
public static void withMetricLogger(final Consumer<MetricsLogger> logger) {
160-
withMetricsLogger(logger);
161-
}
162-
163132
public static DimensionSet[] getDefaultDimensions() {
164133
return Arrays.copyOf(defaultDimensions, defaultDimensions.length);
165134
}

powertools-metrics/src/test/java/software/amazon/lambda/powertools/metrics/MetricsLoggerTest.java

-12
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,6 @@ void metricsLoggerCaptureUtilityWithDefaultNameSpace() {
185185
testLogger(MetricsUtils::withMetricsLogger);
186186
}
187187

188-
@Test
189-
void deprecatedMetricLoggerCaptureUtilityWithDefaultNameSpace() {
190-
testLogger(MetricsUtils::withMetricLogger);
191-
}
192-
193-
@Test
194-
void shouldThrowExceptionWhenDefaultDimensionIsNull() {
195-
assertThatNullPointerException()
196-
.isThrownBy(() -> MetricsUtils.defaultDimensionSet(null))
197-
.withMessage("Null dimension set not allowed");
198-
}
199-
200188
@Test
201189
void shouldUseTraceIdFromSystemPropertyIfEnvVarNotPresent() {
202190
try (MockedStatic<SystemWrapper> mocked = mockStatic(SystemWrapper.class);

powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/Tracing.java

-16
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,6 @@
5050
public @interface Tracing {
5151
String namespace() default "";
5252

53-
/**
54-
* @deprecated As of release 1.2.0, replaced by captureMode()
55-
* in order to support different modes and support via
56-
* environment variables
57-
*/
58-
@Deprecated
59-
boolean captureResponse() default true;
60-
61-
/**
62-
* @deprecated As of release 1.2.0, replaced by captureMode()
63-
* in order to support different modes and support via
64-
* environment variables
65-
*/
66-
@Deprecated
67-
boolean captureError() default true;
68-
6953
String segmentName() default "";
7054

7155
CaptureMode captureMode() default CaptureMode.ENVIRONMENT_VAR;

powertools-tracing/src/main/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspect.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ public Object around(ProceedingJoinPoint pjp,
8383
private boolean captureResponse(Tracing powerToolsTracing) {
8484
switch (powerToolsTracing.captureMode()) {
8585
case ENVIRONMENT_VAR:
86-
boolean captureResponse = environmentVariable("POWERTOOLS_TRACER_CAPTURE_RESPONSE");
87-
return isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_RESPONSE") ? captureResponse :
88-
powerToolsTracing.captureResponse();
86+
return isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_RESPONSE")
87+
&& environmentVariable("POWERTOOLS_TRACER_CAPTURE_RESPONSE");
8988
case RESPONSE:
9089
case RESPONSE_AND_ERROR:
9190
return true;
@@ -98,9 +97,8 @@ private boolean captureResponse(Tracing powerToolsTracing) {
9897
private boolean captureError(Tracing powerToolsTracing) {
9998
switch (powerToolsTracing.captureMode()) {
10099
case ENVIRONMENT_VAR:
101-
boolean captureError = environmentVariable("POWERTOOLS_TRACER_CAPTURE_ERROR");
102-
return isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_ERROR") ? captureError :
103-
powerToolsTracing.captureError();
100+
return isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_ERROR")
101+
&& environmentVariable("POWERTOOLS_TRACER_CAPTURE_ERROR");
104102
case ERROR:
105103
case RESPONSE_AND_ERROR:
106104
return true;

powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/handlers/PowerTracerToolEnabledWithNoMetaDataDeprecated.java

-28
This file was deleted.

powertools-tracing/src/test/java/software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspectTest.java

-24
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledForStreamWithNoMetaData;
4848
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledWithException;
4949
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledWithNoMetaData;
50-
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledWithNoMetaDataDeprecated;
5150
import software.amazon.lambda.powertools.tracing.nonhandler.PowerToolNonHandler;
5251

5352
class LambdaTracingAspectTest {
@@ -246,29 +245,6 @@ void shouldCaptureTracesForStreamWithNoMetadata() throws IOException {
246245
});
247246
}
248247

249-
@Test
250-
void shouldCaptureTracesWithNoMetadataDeprecated() {
251-
requestHandler = new PowerTracerToolEnabledWithNoMetaDataDeprecated();
252-
253-
requestHandler.handleRequest(new Object(), context);
254-
255-
assertThat(AWSXRay.getTraceEntity())
256-
.isNotNull();
257-
258-
assertThat(AWSXRay.getTraceEntity().getSubsegmentsCopy())
259-
.hasSize(1)
260-
.allSatisfy(subsegment ->
261-
{
262-
assertThat(subsegment.getAnnotations())
263-
.hasSize(2)
264-
.containsEntry("ColdStart", true)
265-
.containsEntry("Service", "service_undefined");
266-
267-
assertThat(subsegment.getMetadata())
268-
.isEmpty();
269-
});
270-
}
271-
272248
@Test
273249
void shouldNotCaptureTracesIfDisabledViaEnvironmentVariable() {
274250
try (MockedStatic<SystemWrapper> mocked = mockStatic(SystemWrapper.class)) {

0 commit comments

Comments
 (0)