Skip to content

Commit

Permalink
fix deprecation warnings (#384)
Browse files Browse the repository at this point in the history
Cleanup a number of deprecation warnings and remove some
deprecated methods.
  • Loading branch information
brharrington authored Mar 12, 2019
1 parent e18b6b0 commit ae9ab72
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 75 deletions.
20 changes: 0 additions & 20 deletions iep-admin/src/main/java/com/netflix/iep/admin/AdminServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,6 @@ private void createContext(String path, HttpHandler handler) {
server.createContext(path, new AccessLogHandler(handler));
}

/**
* @deprecated This is a no-op, the server will be automatically started when it
* is constructed.
*/
@Deprecated
public void start() {
}

/**
* @deprecated Use {@link #close()} instead.
*/
@Deprecated
public void stop() {
try {
close();
} catch (Exception e) {
throw new RuntimeException("failed to stop AdminServer", e);
}
}

@Override public void close() throws Exception {
LOGGER.info("shutting down admin on port {}", config.port());
server.stop((int) config.shutdownDelay().toMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.netflix.spectator.api.DefaultRegistry;
import com.netflix.spectator.api.Registry;
import com.netflix.spectator.api.patterns.PolledMeter;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -44,8 +43,7 @@ public SpectatorEndpointTest() {

registry.distributionSummary("distSummary1", "a", "1").record(47);

registry.gauge("gauge1", 100.0);
PolledMeter.update(registry);
registry.gauge("gauge1").set(100.0);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.netflix.iep.config;

import com.netflix.archaius.api.Property;
import com.netflix.archaius.api.PropertyFactory;
import com.netflix.archaius.api.PropertyRepository;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -31,7 +31,7 @@ public class DynamicPropertiesConfiguration implements AutoCloseable {
private final IConfiguration instance;

@Inject
public DynamicPropertiesConfiguration(PropertyFactory factory) {
public DynamicPropertiesConfiguration(PropertyRepository factory) {
instance = new DynamicPropertiesConfigurationInstance(factory);
Configuration.setConfiguration(instance);
}
Expand All @@ -41,17 +41,17 @@ protected IConfiguration getInstance() {
}

protected class DynamicPropertiesConfigurationInstance implements IConfiguration {
private final PropertyFactory factory;
private final PropertyRepository factory;
private final Map<String, Property<String>> props = new ConcurrentHashMap<>();

protected DynamicPropertiesConfigurationInstance(PropertyFactory factory) {
protected DynamicPropertiesConfigurationInstance(PropertyRepository factory) {
this.factory = factory;
}

public String get(String key) {
Property<String> prop = props.get(key);
if (prop == null) {
prop = factory.getProperty(key).asString(null);
prop = factory.get(key, String.class).orElse(null);
props.put(key, prop);
}
return prop.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.junit.Assert.*;

import com.netflix.archaius.DefaultPropertyFactory;
import com.netflix.archaius.api.PropertyFactory;
import com.netflix.archaius.config.MapConfig;
import org.junit.Test;

Expand Down Expand Up @@ -75,7 +74,7 @@ interface TestConfig extends IConfiguration {
private TestConfig mkConfig() { return mkConfig(new HashMap<>()); }
private TestConfig mkConfig(Map<String,String> props) { return mkConfig(null, props); }
private TestConfig mkConfig(String prefix, Map<String,String> props) {
PropertyFactory factory = new DefaultPropertyFactory(new MapConfig(props));
DefaultPropertyFactory factory = new DefaultPropertyFactory(new MapConfig(props));
Configuration.setConfiguration(new DynamicPropertiesConfiguration(factory).getInstance());
return Configuration.newProxy(TestConfig.class, prefix);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import com.netflix.archaius.DefaultPropertyFactory;
import com.netflix.archaius.api.Config;
import com.netflix.archaius.api.PropertyFactory;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -59,7 +58,7 @@ public static void setUp() throws Exception {
put("resources.url", "file://" + userDir + "/src/test/resources");
}};
Config config = TestResourceConfiguration.load("config.test.properties", subs);
PropertyFactory factory = new DefaultPropertyFactory(config);
DefaultPropertyFactory factory = new DefaultPropertyFactory(config);
Configuration.setConfiguration(new DynamicPropertiesConfiguration(factory).getInstance());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,10 @@ private static class AdminServerProvider implements Provider<AdminServer> {
* quick local testing of the module and common endpoints.
*/
public static void main(String[] args) {
Injector injector = Guice.createInjector(new AdminModule(), new AbstractModule() {
Guice.createInjector(new AdminModule(), new AbstractModule() {
@Override protected void configure() {
bind(Registry.class).toInstance(new DefaultRegistry());
}
});
AdminServer server = injector.getInstance(AdminServer.class);
server.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.util.Modules;
import com.netflix.archaius.guice.ArchaiusModule;
import com.netflix.iep.admin.AdminServer;
import com.netflix.iep.admin.guice.AdminModule;
import com.netflix.iep.platformservice.PlatformServiceModule;
import com.netflix.spectator.api.DefaultRegistry;
import com.netflix.spectator.api.Registry;

/**
* Work around for overriding the AppConfig.
Expand All @@ -45,8 +46,10 @@ public final class OverrideModule extends AbstractModule {

public static void main(String[] args) {
System.setProperty("netflix.iep.archaius.use-dynamic", "false");
Injector injector = Guice.createInjector(new OverrideModule());
AdminServer server = injector.getInstance(AdminServer.class);
server.start();
Guice.createInjector(new OverrideModule(), new AdminModule(), new AbstractModule() {
@Override protected void configure() {
bind(Registry.class).toInstance(new DefaultRegistry());
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.multibindings.Multibinder;
import com.netflix.appinfo.ApplicationInfoManager;
Expand All @@ -32,7 +31,6 @@
import com.netflix.discovery.DiscoveryClient;
import com.netflix.discovery.EurekaClientConfig;
import com.netflix.discovery.shared.transport.jersey.Jersey1DiscoveryClientOptionalArgs;
import com.netflix.iep.admin.AdminServer;
import com.netflix.iep.admin.guice.AdminModule;
import com.netflix.iep.service.Service;
import org.apache.commons.configuration.Configuration;
Expand Down Expand Up @@ -107,8 +105,6 @@ private EurekaInstanceConfig provideInstanceConfig(OptionalInjections opts) {

public static void main(String[] args) {
System.setProperty("netflix.iep.archaius.use-dynamic", "false");
Injector injector = Guice.createInjector(new EurekaModule());
AdminServer server = injector.getInstance(AdminServer.class);
server.start();
Guice.createInjector(new EurekaModule());
}
}
14 changes: 0 additions & 14 deletions iep-ses/src/main/java/com/netflix/iep/ses/EmailRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,6 @@ EmailRequestBuilder withBoundary(String boundary) {
return this;
}

/**
* Set the source or from address of the message. If not specified, then it must be
* provided when constructing the {@code SendRawEmailRequest} object.
*
* @deprecated Use {@link #withFromAddress(String)} instead. Renamed to avoid confusion
* as this will set the {@code From} header in the message which behaves differently than
* calling {@code SendRawEmailRequest.withSource} when using sending authorization. Will
* be removed in 2.0.
*/
@Deprecated
public EmailRequestBuilder withSource(String source) {
return withFromAddress(source);
}

/**
* Set the source or from address of the message. If not specified, then it must be
* provided when constructing the {@code SendRawEmailRequest} object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
@RunWith(JUnit4.class)
public class EmailRequestBuilderTest {

private static boolean BLESS = false;
private static boolean SEND = false;
private static final boolean BLESS = false;
private static final boolean SEND = false;

private static String FROM = "bob@example.com";
private static String TO = "andrew@example.com";
private static String CC = "sue@example.com";
private static final String FROM = "bob@example.com";
private static final String TO = "andrew@example.com";
private static final String CC = "sue@example.com";

private static String FROM_ARN = "arn:aws:ses:us-east-1:123456789012:identity/example.com";
private static final String FROM_ARN = "arn:aws:ses:us-east-1:123456789012:identity/example.com";

private static String BOUNDARY = "331239ab-8a31-4cc6-84d6-5557f96ebc3a";
private static final String BOUNDARY = "331239ab-8a31-4cc6-84d6-5557f96ebc3a";

private void writeResource(String name, byte[] data) throws IOException {
// Path ends with: iep-ses/target/test-classes/des-example.png
Expand Down Expand Up @@ -94,15 +94,6 @@ private void checkMessage(String name, EmailRequestBuilder builder) throws IOExc
}
}

@Test
public void simpleTextMessageSource() throws IOException {
checkMessage("simpleTextMessage", new EmailRequestBuilder()
.withSource(FROM)
.withToAddresses(TO)
.withSubject("Test message")
.withTextBody("Body of the email message."));
}

@Test
public void simpleTextMessage() throws IOException {
checkMessage("simpleTextMessage", new EmailRequestBuilder()
Expand Down

0 comments on commit ae9ab72

Please sign in to comment.