Skip to content

Commit

Permalink
Add missing Override annotations and (micronaut-projects#3604)
Browse files Browse the repository at this point in the history
other code clean-up.
  • Loading branch information
croudet38 authored Jun 30, 2020
1 parent 8652089 commit 4d6a732
Show file tree
Hide file tree
Showing 88 changed files with 160 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static class ExecutorServiceSubscription<S> implements Subscription {
* Request execution.
* @param n request number
*/
@Override
public synchronized void request(long n) {
if (n != 0 && !completed) {
completed = true;
Expand All @@ -113,6 +114,7 @@ public synchronized void request(long n) {
/**
* Cancel.
*/
@Override
public synchronized void cancel() {
completed = true;
if (future != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CompletableFutureSubscription implements Subscription {
/**
* @param n Number of elements to request to the upstream
*/
@Override
public synchronized void request(long n) {
if (n != 0 && !completed.get()) {
if (n < 0) {
Expand Down Expand Up @@ -101,6 +102,7 @@ public synchronized void request(long n) {
/**
* Request the publisher to stop sending data and clean up resources.
*/
@Override
public synchronized void cancel() {
if (completed.compareAndSet(false, true)) {
if (future != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ public interface MutableConvertibleMultiValues<V> extends ConvertibleMultiValues
*
* @return This instance
*/
@Override
MutableConvertibleMultiValues<V> clear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public interface BeanExceptionHandler<T, E extends Throwable> extends BiConsumer
* @param bean The bean
* @param throwable The error
*/
@Override
default void accept(@Nullable T bean, @NonNull E throwable) {
handle(bean, throwable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public Stream<URL> getResources(String name) {
* @param basePath The path to load resources
* @return The resource loader
*/
@Override
public ResourceLoader forBase(String basePath) {
return new DefaultFileSystemResourceLoader(basePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static FileSystemResourceLoader defaultLoader() {
* appended by a colon. Ex (classpath:, file:)
* @return boolean
*/
@Override
default boolean supportsPrefix(String path) {
return path.startsWith("file:");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public DefaultClassPathResourceLoader(ClassLoader classLoader, String basePath)
* @param path The path
* @return An optional resource
*/
@Override
public Optional<InputStream> getResourceAsStream(String path) {
if (!isDirectory(path)) {
return Optional.ofNullable(classLoader.getResourceAsStream(prefixPath(path)));
Expand All @@ -85,6 +86,7 @@ public Optional<InputStream> getResourceAsStream(String path) {
* @param path The path
* @return An optional resource
*/
@Override
public Optional<URL> getResource(String path) {
boolean isDirectory = isDirectory(path);

Expand All @@ -101,6 +103,7 @@ public Optional<URL> getResource(String path) {
* @param path The path
* @return A resource stream
*/
@Override
public Stream<URL> getResources(String path) {
Enumeration<URL> all;
try {
Expand All @@ -119,6 +122,7 @@ public Stream<URL> getResources(String path) {
/**
* @return The class loader used to retrieve resources
*/
@Override
public ClassLoader getClassLoader() {
return classLoader;
}
Expand All @@ -127,6 +131,7 @@ public ClassLoader getClassLoader() {
* @param basePath The path to load resources
* @return The resouce loader
*/
@Override
public ResourceLoader forBase(String basePath) {
return new DefaultClassPathResourceLoader(classLoader, basePath);
}
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/io/micronaut/core/type/Argument.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public interface Argument<T> extends TypeVariableResolver, AnnotatedElement, Typ
/**
* @return The name of the argument
*/
@Override
@NonNull String getName();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import io.micronaut.discovery.consul.ConsulServiceInstance;
import io.micronaut.http.client.annotation.Client;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.util.ArrayList;
Expand All @@ -52,8 +50,6 @@ public abstract class AbstractConsulClient implements ConsulClient {
static final String EXPR_CONSUL_CONFIG_RETRY_COUNT = "${" + ConsulConfiguration.ConsulConfigDiscoveryConfiguration.PREFIX + ".retry-count:3}";
static final String EXPR_CONSUL_CONFIG_RETRY_DELAY = "${" + ConsulConfiguration.ConsulConfigDiscoveryConfiguration.PREFIX + ".retry-delay:1s}";

private static final Logger LOG = LoggerFactory.getLogger(AbstractConsulClient.class);

private ConsulConfiguration consulConfiguration = new ConsulConfiguration();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public ServiceEntry(AbstractServiceEntry entry) {
*
* @return The name of the service
*/
@Override
public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ public AmazonInfo autoBuild(EurekaConfiguration config) {
} catch (InterruptedException e1) {

}
continue;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public Publisher<PropertySource> getPropertySources(Environment environment) {

for (ListSecretsResponse response : responses) {
retrieved += response.getItems().size();
response.getItems().forEach((summary) -> {
response.getItems().forEach(summary -> {
String secretValue = getSecretValue(summary.getId());
secrets.put(
summary.getSecretName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,24 @@ public void process(BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> met
routes.add(GET(functionPath, beanDefinition, method));
routes.add(HEAD(functionPath, beanDefinition, method));
} else {
if (StringUtils.isNotEmpty(functionMethod)) {
if (functionMethod.equals(methodName)) {
Argument[] argumentTypes = method.getArguments();
int argCount = argumentTypes.length;
if (argCount < 3) {
String functionPath = resolveFunctionPath(methodName, declaringType, functionName);
if (argCount == 0) {
routes.add(GET(functionPath, beanDefinition, method));
routes.add(HEAD(functionPath, beanDefinition, method));
} else {
UriRoute route = POST(functionPath, beanDefinition, method);
routes.add(route);
if (argCount == 2 || !ClassUtils.isJavaLangType(argumentTypes[0].getType())) {
if (consumes == null) {
consumes = new MediaType[] {MediaType.APPLICATION_JSON_TYPE};
}
} else {
route.body(method.getArgumentNames()[0])
.consumesAll();
if (StringUtils.isNotEmpty(functionMethod) && functionMethod.equals(methodName)) {
Argument[] argumentTypes = method.getArguments();
int argCount = argumentTypes.length;
if (argCount < 3) {
String functionPath = resolveFunctionPath(methodName, declaringType, functionName);
if (argCount == 0) {
routes.add(GET(functionPath, beanDefinition, method));
routes.add(HEAD(functionPath, beanDefinition, method));
} else {
UriRoute route = POST(functionPath, beanDefinition, method);
routes.add(route);
if (argCount == 2 || !ClassUtils.isJavaLangType(argumentTypes[0].getType())) {
if (consumes == null) {
consumes = new MediaType[] {MediaType.APPLICATION_JSON_TYPE};
}
} else {
route.body(method.getArgumentNames()[0])
.consumesAll();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public String getMessage() {
/**
* @return The {@link HttpResponse}
*/
@Override
public HttpResponse<?> getResponse() {
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ClientRedirectSpec extends Specification {
Publishers.just(ServiceInstance.of(url.getHost(), url))
}

@Override
Optional<String> getContextPath() {
Optional.of("/test")
}
Expand All @@ -105,6 +106,7 @@ class ClientRedirectSpec extends Specification {
Publishers.just(ServiceInstance.of(url.getHost(), url))
}

@Override
Optional<String> getContextPath() {
Optional.of("test")
}
Expand All @@ -130,6 +132,7 @@ class ClientRedirectSpec extends Specification {
Publishers.just(ServiceInstance.of(url.getHost(), url))
}

@Override
Optional<String> getContextPath() {
Optional.of("/test")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
awaiting100ContinueMessage.subscribe(new CancelledSubscriber<>());
awaiting100ContinueMessage = null;
awaiting100Continue.onSubscribe(new Subscription() {
@Override
public void request(long n) {
}

@Override
public void cancel() {
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RequestCertificateSpec extends AbstractMicronautSpec {
response.body() == "O=Test CA,ST=Some-State,C=US"
}

@Override
Map<String, Object> getConfiguration() {
super.getConfiguration() << [
'micronaut.ssl.enabled': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class HttpResponseSpec extends AbstractMicronautSpec {
Integer age
}

@Override
Map<String, Object> getConfiguration() {
super.getConfiguration() << ['micronaut.server.dateHeader': false]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class NettyCorsSpec extends AbstractMicronautSpec {
ex.response.header(VARY) == ORIGIN
}

@Override
Map<String, Object> getConfiguration() {
['micronaut.server.cors.enabled': true,
'micronaut.server.cors.configurations.foo.allowedOrigins': ['foo.com'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.micronaut.http.server.netty.AbstractMicronautSpec

class HttpFilterContextPathSpec extends AbstractMicronautSpec {

@Override
Map<String, Object> getConfiguration() {
super.getConfiguration() << ['micronaut.server.context-path': '/context/path']
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ class StaticResourceResolutionSpec extends AbstractMicronautSpec {
tempFile
}

@Override
Map<String, Object> getConfiguration() {
['micronaut.router.static-resources.default.paths': ['classpath:public', 'file:' + tempFile.parent]]
}

@Override
void cleanupSpec() {
tempFile.delete()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SslFileTypeHandlerSpec extends AbstractMicronautSpec {
response.body() == "<html><head></head><body>HTML Page</body></html>"
}

@Override
Map<String, Object> getConfiguration() {
super.getConfiguration() << ['micronaut.ssl.enabled': true, 'micronaut.ssl.buildSelfSigned': true]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ public interface ServerFilterChain extends FilterChain {
* @param request The current request
* @return A {@link Publisher} for the Http response
*/
@Override
Publisher<MutableHttpResponse<?>> proceed(HttpRequest<?> request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class LoadedVisitor implements Ordered {
return getVisitor().getOrder()
}

@Override
boolean equals(o) {
if (this.is(o)) return true
if (getClass() != o.class) return false
Expand All @@ -92,6 +93,7 @@ class LoadedVisitor implements Ordered {
return true
}

@Override
int hashCode() {
return visitor.getClass().hashCode()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import javax.inject.Singleton
class V6Engine implements Engine { // <2>
int cylinders = 6

@Override
String start() {
"Starting V6"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import javax.inject.Singleton
class V8Engine implements Engine { // <3>
int cylinders = 8

@Override
String start() {
"Starting V8"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class BeanWithPreDestroySpec extends Specification{
return a
}

@Override
@PreDestroy
void close() {
noArgsDestroyCalled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import javax.inject.Inject

abstract class GasEngine extends Engine {

@Override
void injectTwiceOverriddenWithOmissionInMiddle() {
overriddenTwiceWithOmissionInMiddleInjected = true
}

@Override
@Inject
void injectTwiceOverriddenWithOmissionInSubclass() {
overriddenTwiceWithOmissionInSubclassInjected = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class V8Engine extends GasEngine {
publicNoArgsConstructorInjected = true
}

@Override
@Inject @PackageScope void injectPackagePrivateMethod() {
if (subPackagePrivateMethodInjected) {
overriddenPackagePrivateMethodInjectedTwice = true
Expand All @@ -37,6 +38,7 @@ class V8Engine extends GasEngine {
/**
* Qualifiers are swapped from how they appear in the superclass.
*/
@Override
void injectQualifiers(Seat seatA, @Drivers Seat seatB,
Tire tireA, @Named("spare") Tire tireB) {
if ((seatA instanceof DriversSeat)
Expand All @@ -47,15 +49,18 @@ class V8Engine extends GasEngine {
}
}

@Override
@PackageScope void injectPackagePrivateMethodForOverride() {
subPackagePrivateMethodForOverrideInjected = true
}

@Override
@Inject
void injectTwiceOverriddenWithOmissionInMiddle() {
overriddenTwiceWithOmissionInMiddleInjected = true
}

@Override
void injectTwiceOverriddenWithOmissionInSubclass() {
overriddenTwiceWithOmissionInSubclassInjected = true
}
Expand Down
Loading

0 comments on commit 4d6a732

Please sign in to comment.