Skip to content

updates format, and verifies format on build #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
plugins {
id 'com.gradle.build-scan' version '1.16'

id 'com.github.sherter.google-java-format' version '0.7.1'
id 'com.github.sherter.google-java-format' version '0.7.1' apply false
id 'com.jfrog.artifactory' version '4.7.3' apply false
id 'com.jfrog.bintray' version '1.8.4' apply false
id 'me.champeau.gradle.jmh' version '0.4.7' apply false
Expand All @@ -27,6 +27,7 @@ plugins {

subprojects {
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.github.sherter.google-java-format'

ext['reactor-bom.version'] = 'Californium-SR3'
ext['logback.version'] = '1.2.3'
Expand All @@ -42,6 +43,10 @@ subprojects {
ext['micrometer.version'] = '1.0.6'
ext['assertj.version'] = '3.11.1'

googleJavaFormat {
toolVersion = '1.6'
}

dependencyManagement {
imports {
mavenBom "io.projectreactor:reactor-bom:${ext['reactor-bom.version']}"
Expand Down Expand Up @@ -188,10 +193,6 @@ buildScan {

description = 'RSocket: Stream Oriented Messaging Passing with Reactive Stream Semantics.'

googleJavaFormat {
toolVersion = '1.5'
}

repositories {
mavenCentral()
}
4 changes: 2 additions & 2 deletions rsocket-core/src/jmh/java/io/rsocket/frame/FrameTypePerf.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

@BenchmarkMode(Mode.Throughput)
@Fork(
value = 1 // , jvmArgsAppend = {"-Dio.netty.leakDetection.level=advanced"}
)
value = 1 // , jvmArgsAppend = {"-Dio.netty.leakDetection.level=advanced"}
)
@Warmup(iterations = 10)
@Measurement(iterations = 10)
@State(Scope.Thread)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void setup(Blackhole bh) {
this.bh = bh;
this.frameType = FrameType.REQUEST_RESPONSE;
allocator = ByteBufAllocator.DEFAULT;

// Encode a payload and then copy it a single bytebuf
payload = allocator.buffer();
ByteBuf encode =
Expand Down
53 changes: 27 additions & 26 deletions rsocket-core/src/main/java/io/rsocket/ConnectionSetupPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,106 +22,107 @@
import io.rsocket.frame.SetupFrameFlyweight;

/**
* Exposed to server for determination of ResponderRSocket based on mime types and SETUP metadata/data
* Exposed to server for determination of ResponderRSocket based on mime types and SETUP
* metadata/data
*/
public abstract class ConnectionSetupPayload extends AbstractReferenceCounted implements Payload {

public static ConnectionSetupPayload create(final ByteBuf setupFrame) {
return new DefaultConnectionSetupPayload(setupFrame);
}

public abstract int keepAliveInterval();

public abstract int keepAliveMaxLifetime();

public abstract String metadataMimeType();

public abstract String dataMimeType();

public abstract int getFlags();

public abstract boolean willClientHonorLease();

@Override
public ConnectionSetupPayload retain() {
super.retain();
return this;
}

@Override
public ConnectionSetupPayload retain(int increment) {
super.retain(increment);
return this;
}

public abstract ConnectionSetupPayload touch();

public abstract ConnectionSetupPayload touch(Object hint);

private static final class DefaultConnectionSetupPayload extends ConnectionSetupPayload {
private final ByteBuf setupFrame;

public DefaultConnectionSetupPayload(ByteBuf setupFrame) {
this.setupFrame = setupFrame;
}

@Override
public boolean hasMetadata() {
return FrameHeaderFlyweight.hasMetadata(setupFrame);
}

@Override
public int keepAliveInterval() {
return SetupFrameFlyweight.keepAliveInterval(setupFrame);
}

@Override
public int keepAliveMaxLifetime() {
return SetupFrameFlyweight.keepAliveMaxLifetime(setupFrame);
}

@Override
public String metadataMimeType() {
return SetupFrameFlyweight.metadataMimeType(setupFrame);
}

@Override
public String dataMimeType() {
return SetupFrameFlyweight.dataMimeType(setupFrame);
}

@Override
public int getFlags() {
return FrameHeaderFlyweight.flags(setupFrame);
}

@Override
public boolean willClientHonorLease() {
return SetupFrameFlyweight.honorLease(setupFrame);
}

@Override
public ConnectionSetupPayload touch() {
setupFrame.touch();
return this;
}

@Override
public ConnectionSetupPayload touch(Object hint) {
setupFrame.touch(hint);
return this;
}

@Override
protected void deallocate() {
setupFrame.release();
}

@Override
public ByteBuf sliceMetadata() {
return SetupFrameFlyweight.metadata(setupFrame);
}

@Override
public ByteBuf sliceData() {
return SetupFrameFlyweight.data(setupFrame);
Expand Down
7 changes: 3 additions & 4 deletions rsocket-core/src/main/java/io/rsocket/DuplexConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

package io.rsocket;

import java.nio.channels.ClosedChannelException;

import io.netty.buffer.ByteBuf;
import java.nio.channels.ClosedChannelException;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import reactor.core.publisher.Flux;
Expand All @@ -28,8 +27,8 @@
public interface DuplexConnection extends Availability, Closeable {

/**
* Sends the source of Frames on this connection and returns the {@code Publisher}
* representing the result of this send.
* Sends the source of Frames on this connection and returns the {@code Publisher} representing
* the result of this send.
*
* <h2>Flow control</h2>
*
Expand Down
14 changes: 9 additions & 5 deletions rsocket-core/src/main/java/io/rsocket/KeepAliveHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import io.rsocket.frame.KeepAliveFrameFlyweight;
import java.time.Duration;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoProcessor;
import reactor.core.publisher.UnicastProcessor;

import java.time.Duration;

abstract class KeepAliveHandler implements Disposable {
private final KeepAlive keepAlive;
private final UnicastProcessor<ByteBuf> sent = UnicastProcessor.create();
Expand Down Expand Up @@ -45,8 +44,12 @@ public void dispose() {
public void receive(ByteBuf keepAliveFrame) {
this.lastReceivedMillis = System.currentTimeMillis();
if (KeepAliveFrameFlyweight.respondFlag(keepAliveFrame)) {
doSend(KeepAliveFrameFlyweight.encode(ByteBufAllocator.DEFAULT, false, 0,
KeepAliveFrameFlyweight.data(keepAliveFrame).retain()));
doSend(
KeepAliveFrameFlyweight.encode(
ByteBufAllocator.DEFAULT,
false,
0,
KeepAliveFrameFlyweight.data(keepAliveFrame).retain()));
}
}

Expand Down Expand Up @@ -92,7 +95,8 @@ private static final class Client extends KeepAliveHandler {
@Override
void onIntervalTick() {
doCheckTimeout();
doSend(KeepAliveFrameFlyweight.encode(ByteBufAllocator.DEFAULT, true, 0, Unpooled.EMPTY_BUFFER));
doSend(
KeepAliveFrameFlyweight.encode(ByteBufAllocator.DEFAULT, true, 0, Unpooled.EMPTY_BUFFER));
}
}

Expand Down
15 changes: 7 additions & 8 deletions rsocket-core/src/main/java/io/rsocket/RSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@
import io.rsocket.internal.LimitableRequestPublisher;
import io.rsocket.internal.UnboundedProcessor;
import io.rsocket.internal.UnicastMonoProcessor;
import org.reactivestreams.Processor;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.SignalType;
import reactor.core.publisher.UnicastProcessor;

import java.nio.channels.ClosedChannelException;
import java.time.Duration;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.function.Consumer;
import org.reactivestreams.Processor;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.SignalType;
import reactor.core.publisher.UnicastProcessor;

/** Client Side of a RSocket socket. Sends {@link ByteBuf}s to a {@link RSocketServer} */
class RSocketClient implements RSocket {
Expand Down
3 changes: 1 addition & 2 deletions rsocket-core/src/main/java/io/rsocket/RSocketFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
import io.rsocket.transport.ClientTransport;
import io.rsocket.transport.ServerTransport;
import io.rsocket.util.EmptyPayload;
import reactor.core.publisher.Mono;

import java.time.Duration;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import reactor.core.publisher.Mono;

/** Factory for creating RSocket clients and servers. */
public class RSocketFactory {
Expand Down
7 changes: 3 additions & 4 deletions rsocket-core/src/main/java/io/rsocket/RSocketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import io.rsocket.frame.decoder.PayloadDecoder;
import io.rsocket.internal.LimitableRequestPublisher;
import io.rsocket.internal.UnboundedProcessor;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import org.reactivestreams.Processor;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
Expand All @@ -36,10 +39,6 @@
import reactor.core.publisher.SignalType;
import reactor.core.publisher.UnicastProcessor;

import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;

/** Server side RSocket. Receives {@link ByteBuf}s from a {@link RSocketClient} */
class RSocketServer implements RSocket {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

package io.rsocket.exceptions;

import static io.rsocket.frame.ErrorFrameFlyweight.*;

import io.netty.buffer.ByteBuf;
import io.rsocket.frame.ErrorFrameFlyweight;

import java.util.Objects;

import static io.rsocket.frame.ErrorFrameFlyweight.*;

/** Utility class that generates an exception from a frame. */
public final class Exceptions {

Expand Down
Loading