diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractBindingHandler.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractBindingHandler.java
index 6bb49cc4cc..ef1039824b 100644
--- a/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractBindingHandler.java
+++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractBindingHandler.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018 Payara Services Ltd.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -163,7 +164,7 @@ public Connection> bind(final String host, final PortRange portRange,
/**
* This operation is not supported by implementations of {@link AbstractBindingHandler}.
*
- * @throws UnsupportedOperationException
+ * @throws UnsupportedOperationException by default
*/
@Override
public final void unbindAll() {
diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractSocketConnectorHandler.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractSocketConnectorHandler.java
index 544e4aedaf..96af01f250 100644
--- a/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractSocketConnectorHandler.java
+++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/AbstractSocketConnectorHandler.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018 Payara Services Ltd.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -140,6 +141,7 @@ public void addMonitoringProbe(ConnectionProbe probe) {
* Remove the {@link ConnectionProbe}.
*
* @param probe the {@link ConnectionProbe}.
+ * @return true if probe was in the list and is now removed
*/
public boolean removeMonitoringProbe(ConnectionProbe probe) {
return probes.remove(probe);
@@ -190,7 +192,7 @@ protected void onComplete() {
/**
* Builder
*
- * @param
Buffer
*/
Buffer slice(int position, int limit);
@@ -349,7 +357,7 @@ public interface Buffer extends Comparable* src.get(a, 0, a.length)* + * @param dst destination array to put the bytes into * @return This buffer - * * @throws BufferUnderflowException * If there are fewer than length bytes * remaining in this buffer @@ -455,11 +463,11 @@ public interface Buffer extends Comparable
- * for (int i = off; i < off + len; i++) + * for (int i = off; i < off + len; i++) * dst[i] = src.get();* * except that it first checks that there are sufficient bytes in - * this buffer and it is potentially much more efficient. + * this buffer and it is potentially much more efficient. * * @param dst * The array into which bytes are to be written @@ -496,6 +504,7 @@ public interface Buffer extends Comparable
* src.get(a, 0, a.remaining())* + * @param dst destination {@link ByteBuffer} to put the data into * @return This buffer * * @throws BufferUnderflowException @@ -524,11 +533,11 @@ public interface Buffer extends Comparable
- * for (int i = off; i < off + len; i++) + * for (int i = off; i < off + len; i++) * dst.put(i) = src.get();* * except that it first checks that there are sufficient bytes in - * this buffer and it is potentially much more efficient. + * this buffer and it is potentially much more efficient. * * @param dst * The {@link ByteBuffer} into which bytes are to be written @@ -580,7 +589,7 @@ public interface Buffer extends Comparable
Otherwise, this method copies
* n = length bytes from the given
- * postion in the source buffer into this buffer, starting from
+ * position in the source buffer into this buffer, starting from
* the current buffer position.
* The positions of this buffer is then incremented by length.
*
@@ -622,11 +631,12 @@ public interface Buffer extends Comparable
- * for (int i = 0; i < length; i++)
- * dst.put(src.get(i + position));
+ * for (int i = 0; i < length; i++)
+ * dst.put(src.get(i + position));
+ *
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient.
Otherwise, this method copies
* n = length bytes from the given
- * postion in the source buffer into this buffer, starting from
+ * position in the source buffer into this buffer, starting from
* the current buffer position.
* The positions of this buffer is then incremented by length.
*
@@ -716,11 +726,11 @@ public interface Buffer extends Comparable
- * for (int i = 0; i < length; i++)
+ * for (int i = 0; i < length; i++)
* dst.put(src.get(i + position));
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient.
* dst.put(a, 0, a.length)* + * @param src source of bytes to put into the Buffer * @return This buffer * * @throws BufferOverflowException @@ -785,11 +796,11 @@ public interface Buffer extends Comparable
- * for (int i = off; i < off + len; i++) + * for (int i = off; i < off + len; i++) * dst.put(a[i]);* * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient. + * buffer and it is potentially much more efficient. * * @param src * The array from which bytes are to be read @@ -835,11 +846,11 @@ public interface Buffer extends Comparable
- * for (int i = 0; i < src.length(); i++) + * for (int i = 0; i < src.length(); i++) * dst.put((byte) src.charAt(i));* * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient. + * buffer and it is potentially much more efficient. * * @param s * The {@link String} from which bytes are to be read @@ -882,7 +893,7 @@ public interface Buffer extends Comparable
* buf.clear(); // Prepare buffer for use * for (;;) { - * if (in.read(buf) < 0 && !buf.hasRemaining()) + * if (in.read(buf) < 0 && !buf.hasRemaining()) * break; // No more bytes to transfer * buf.flip(); * out.write(buf); @@ -911,7 +922,7 @@ public interface Buffer extends Comparable, WritableMessage { ByteOrder order(); /** - * Modifies this buffer's byte order. + * Modifies this buffer's byte order. * * @param bo * The new byte order, @@ -1412,7 +1423,7 @@ public interface Buffer extends Comparable , WritableMessage { /** * Returns {@link Buffer} content as {@link String} * @param charset the {@link Charset}, which will be use - * for byte[] -> {@link String} transformation. + * for byte[] -> {@link String} transformation. * * @return {@link String} representation of this {@link Buffer} content. */ @@ -1421,7 +1432,7 @@ public interface Buffer extends Comparable , WritableMessage { /** * Returns {@link Buffer}'s chunk content as {@link String} * @param charset the {@link Charset}, which will be use - * for byte[] -> {@link String} transformation. + * for byte[] -> {@link String} transformation. * @param position the first byte offset in the Buffer (inclusive) * @param limit the last byte offset in the Buffer (exclusive) * @@ -1455,7 +1466,7 @@ public interface Buffer extends Comparable , WritableMessage { * guaranteed to be independent, so it's recommended to save and restore * position, limit values if it is planned to change them or * {@link ByteBuffer#slice()} the returned {@link ByteBuffer}. - * + * * * @return this Buffer
as a {@link ByteBuffer}. */ @@ -1476,8 +1487,7 @@ public interface Buffer extends Comparable, WritableMessage { * guaranteed to be independent, so it's recommended to save and restore * position, limit values if it is planned to change them or * {@link ByteBuffer#slice()} the returned {@link ByteBuffer}. - * - * + * * @param position the position for the starting subsequence for the * returned {@link ByteBuffer}. * @param limit the limit for the ending of the subsequence of the @@ -1513,6 +1523,7 @@ public interface Buffer extends Comparable , WritableMessage { * {@link CompositeBuffer} or not. * * + * @param array this buffer as a {@link ByteBufferArray} * @return returns the provided {@link ByteBufferArray} with the converted * {@link ByteBuffer} added to provided array
. * @@ -1549,6 +1560,9 @@ public interface Buffer extends Comparable, WritableMessage { * {@link CompositeBuffer} or not. * * + * @param array the {@link ByteBufferArray} to append this to + * @param position the start position within the source buffer
+ * @param limit the limit, or number, of bytes to include in the resulting {@link ByteBuffer} * @return returns the provided {@link ByteBufferArray} with the converted * {@link ByteBuffer} added to providedarray
. * @@ -1578,6 +1592,7 @@ public interface Buffer extends Comparable, WritableMessage { * {@link CompositeBuffer} or not. * * + * @param array the base array to append to * @return Returns the specified {@link BufferArray} after adding this Buffer
. */ BufferArray toBufferArray(BufferArray array); @@ -1608,6 +1623,7 @@ public interface Buffer extends Comparable, WritableMessage { * {@link CompositeBuffer} or not. * * + * @param array the {@link BufferArray} to prepend to * @param position the new position for this Buffer
* @param limit the new limit for thisBuffer
* diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/CloseReason.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/CloseReason.java index ac3adcbeac..40cdc5a678 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/CloseReason.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/CloseReason.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2013, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -68,8 +69,8 @@ public CloseType getType() { * Returns information about an error, that caused the {@link Connection} to * be closed. * - * If the cause wasn't specified by user - the default value {@link #DEFAULT_CAUSE} will be returned. - * + * If the cause wasn't specified by user and it was closed locally then {@link #LOCALLY_CLOSED} will be returned. + * If the cause wasn't specified by user and it was closed remotely then {@link #REMOTELY_CLOSED} will be returned. * @return information about an error, that caused the {@link Connection} to * be closed */ diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Closeable.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Closeable.java index 7d7a3052bd..7a65f5cbcd 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Closeable.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Closeable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2010, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -25,6 +26,7 @@ * Closeable interface contains two sets of methods: close* and terminate*, * so interface implementations can provide graceful and abrupt releasing of resources. * + * @see java.io.Closeable * @author Alexey Stashok */ public interface Closeable { @@ -40,11 +42,9 @@ public interface Closeable { /** * Checks if this Closeable is open and ready to be used. - * If this Closeable is closed - this method throws - * {@link IOException} giving the reason why this Closeable + * If this Closeable is closed then an IOException will be thrown + * @throws IOException giving the reason why this Closeable * was closed. - * - * @throws IOException */ void assertOpen() throws IOException; @@ -73,7 +73,8 @@ public interface Closeable { * This method is similar to {@link #terminateSilently()}, but additionally * provides the reason why the Closeable will be closed. * - * @param cause + * @param cause reason why terminated. This will be thrown is + * {@link #isOpen()} is called subsequently */ void terminateWithReason(IOException cause); @@ -96,6 +97,7 @@ public interface Closeable { * * @return {@link java.util.concurrent.Future}, which could be checked in case, if close operation * will be run asynchronously + * @see java.io.Closeable#close() which is not asynchronous */ GrizzlyFutureclose(); @@ -120,7 +122,8 @@ public interface Closeable { * This method is similar to {@link #closeSilently()}, but additionally * provides the reason why the Closeable will be closed. * - * @param cause + * @param cause reason why closed, this will be thrown by + * {@link #isOpen()} if called subsequently */ void closeWithReason(IOException cause); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Connection.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Connection.java index 8efb4c7236..0d821caf11 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Connection.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Connection.java @@ -59,7 +59,6 @@ public interface Connection extends Readable , Writeable , * {@link IOException} giving the reason why this Connection * was closed. * - * @throws IOException */ @Override void assertOpen() throws IOException; @@ -104,7 +103,7 @@ public interface Connection extends Readable , Writeable , * {@link ProcessorSelector}, associated withthe {@link Connection} is also * null - will ask {@link Transport} for a {@link Processor}. * - * @param ioEvent + * @param ioEvent event to obtain the processor for * @return the default {@link Processor}, which will process * {@link Connection} I/O events. */ @@ -167,9 +166,9 @@ void setProcessorSelector( /** * Returns the {@link Processor} state associated with this Connection. - * @param + * @param state of the {@link Processor} * @param processor {@link Processor} - * @param factory + * @param factory factory that is used to initialise the state * * @return the {@link Processor} state associated with this Connection. */ @@ -182,13 +181,14 @@ E obtainProcessorState(Processor processor, * The thread will be chosen based on {@link #getTransport() Transport} * settings, especially current I/O strategy. * - * @param event - * @param runnable + * @param event event to get the thread pool from + * @param runnable Runnable to run in the thread */ void executeInEventThread(IOEvent event, Runnable runnable); /** - * @return an associated {@link MemoryManager}. It's a shortcut for {@link #getTransport()#getMemoryManager()} + * @return an associated {@link MemoryManager}. It's a shortcut for + * {@link #getTransport()}{@link Transport#getMemoryManager() .getMemoryManager()} * @since 2.3.18 */ MemoryManager> getMemoryManager(); @@ -268,9 +268,10 @@ E obtainProcessorState(Processor processor, /** * Returns the current value for the blocking read timeout converted to the * provided {@link TimeUnit} specification. If this value hasn't been - * explicitly set, it will default to {@value #DEFAULT_READ_TIMEOUT} seconds. + * explicitly set, it will default to 30 seconds. * * @param timeUnit the {@link TimeUnit} to convert the returned result to. + * @return the read timeout value * * @since 2.3 */ @@ -282,7 +283,7 @@ E obtainProcessorState(Processor processor, * A value of zero or less effectively disables the timeout. * * @param timeout the new timeout value - * @param timeUnit the {@TimeUnit} specification of the provided value. + * @param timeUnit the {@link TimeUnit} specification of the provided value. * * @see Connection#setReadTimeout(long, java.util.concurrent.TimeUnit) * @@ -293,9 +294,10 @@ E obtainProcessorState(Processor processor, /** * Returns the current value for the blocking write timeout converted to the * provided {@link TimeUnit} specification. If this value hasn't been - * explicitly set, it will default to {@value #DEFAULT_WRITE_TIMEOUT} seconds. + * explicitly set, it will default to 30 seconds. * * @param timeUnit the {@link TimeUnit} to convert the returned result to. + * @return the write timeout value * * @since 2.3 */ @@ -307,7 +309,7 @@ E obtainProcessorState(Processor processor, * A value of zero or less effectively disables the timeout. * * @param timeout the new timeout value - * @param timeUnit the {@TimeUnit} specification of the provided value. + * @param timeUnit the {@link TimeUnit} specification of the provided value. * * @see Connection#setWriteTimeout(long, java.util.concurrent.TimeUnit) * @@ -349,7 +351,6 @@ E obtainProcessorState(Processor processor, * This method is similar to {@link #terminateSilently()}, but additionally * provides the reason why the Connection will be closed. * - * @param reason */ @Override void terminateWithReason(IOException reason); @@ -386,8 +387,7 @@ E obtainProcessorState(Processor processor, * * This method is similar to {@link #closeSilently()}, but additionally * provides the reason why the Connection will be closed. - * - * @param reason + * */ @Override void closeWithReason(IOException reason); @@ -427,6 +427,7 @@ E obtainProcessorState(Processor processor, * Remove the {@link CloseListener}. * * @param closeListener {@link CloseListener}. + * @return true if listener successfully removed * * @deprecated use {@link #removeCloseListener(org.glassfish.grizzly.CloseListener)} */ diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/FileTransfer.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/FileTransfer.java index 8415cfdc81..32ac6e0fec 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/FileTransfer.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/FileTransfer.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2011, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -117,8 +118,9 @@ public FileTransfer(final File f, final long pos, final long len) { * {@link WritableByteChannel}. * * @param c the {@link WritableByteChannel} - * @return - * @throws IOException + * @return the number of bytes that have been transferred + * @throws IOException if an error occurs while processing + * @see java.nio.channels.FileChannel#transferTo(long, long, java.nio.channels.WritableByteChannel) */ public long writeTo(final WritableByteChannel c) throws IOException { final long written = fileChannel.transferTo(pos, len, c); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/IOEventLifeCycleListener.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/IOEventLifeCycleListener.java index e15fcf5513..e1a569f2b5 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/IOEventLifeCycleListener.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/IOEventLifeCycleListener.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2010, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -28,16 +29,16 @@ public interface IOEventLifeCycleListener { /** * {@link IOEvent} processing suspended. * - * @param context - * @throws IOException + * @param context IO Context + * @throws IOException on error */ void onContextSuspend(Context context) throws IOException; /** * {@link IOEvent} processing resumed. * - * @param context - * @throws IOException + * @param context IO Context + * @throws IOException on error */ void onContextResume(Context context) throws IOException; @@ -47,31 +48,32 @@ public interface IOEventLifeCycleListener { * {@link Connection#disableIOEvent(org.glassfish.grizzly.IOEvent)} might be * explicitly called. * - * @param context + * @param context IO Context on error */ void onContextManualIOEventControl(final Context context) throws IOException; /** * Reregister {@link IOEvent} interest. * - * @param context - * @throws IOException + * @param context IO Context + * @throws IOException on error */ void onReregister(Context context) throws IOException; /** * {@link IOEvent} processing completed. * - * @param context - * @throws IOException + * @param context IO Context + * @param data data produced + * @throws IOException on error */ void onComplete(Context context, Object data) throws IOException; /** * Detaching {@link IOEvent} processing out of this {@link Context}. * - * @param context - * @throws IOException + * @param context IO Context + * @throws IOException on error */ void onLeave(Context context) throws IOException; @@ -79,8 +81,8 @@ public interface IOEventLifeCycleListener { * Terminate {@link IOEvent} processing in this thread, but it's going to * be continued later. * - * @param context - * @throws IOException + * @param context IO Context + * @throws IOException on error * * @deprecated will never be invoked */ @@ -91,21 +93,24 @@ public interface IOEventLifeCycleListener { * * @param context original {@link Context} to be rerun * @param newContext new context, which will replace original {@link Context} - * @throws IOException + * @throws IOException on error */ void onRerun(Context context, Context newContext) throws IOException; /** * Error occurred during {@link IOEvent} processing. * - * @param context + * @param context IO Context + * @param description description of error. This may be ignored. + * @throws java.io.IOException on error */ void onError(Context context, Object description) throws IOException; /** * {@link IOEvent} wasn't processed. * - * @param context + * @param context IO Context on error + * @throws java.io.IOException on error */ void onNotRun(Context context) throws IOException; diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/IOStrategy.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/IOStrategy.java index 9ff94775d1..32a7a22fd5 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/IOStrategy.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/IOStrategy.java @@ -81,8 +81,8 @@ boolean executeIoEvent(Connection connection, IOEvent ioEvent, * processing for the given connection. A null value will * be returned if the ioEvent should be executed in the kernel thread. * - * @param connection - * @param ioEvent + * @param connection {@link Connection} + * @param ioEvent the event to get the Executor for * @return an {@link Executor} to be used to run given ioEvent * processing for the given connection */ diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/NIOTransportBuilder.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/NIOTransportBuilder.java index 9d9278ed10..5c9f945eaf 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/NIOTransportBuilder.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/NIOTransportBuilder.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2011, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -101,7 +102,7 @@ protected NIOTransportBuilder(final Class extends NIOTransport> transportClass // ---------------------------------------------------------- Public Methods /** - * @return the number of {@link Selector}s to be created to serve Transport + * @return the number of {@link java.nio.channels.Selector}s to be created to serve Transport * connections. -1 is the default value, which lets the Transport * to pick the value, usually it's equal to the number of CPU cores * {@link Runtime#availableProcessors()} @@ -111,12 +112,12 @@ public int getSelectorRunnersCount() { } /** - * Sets the number of {@link Selector}s to be created to serve Transport + * Sets the number of {@link java.nio.channels.Selector}s to be created to serve Transport * connections. -1 is the default value, which lets the Transport * to pick the value, usually it's equal to the number of CPU cores * {@link Runtime#availableProcessors()}. * - * @param selectorRunnersCount + * @param selectorRunnersCount number of channels * @return the builder */ public T setSelectorRunnersCount(final int selectorRunnersCount) { @@ -138,6 +139,8 @@ public ThreadPoolConfig getWorkerThreadPoolConfig() { * Sets the {@link ThreadPoolConfig} that will be used to construct the * {@link java.util.concurrent.ExecutorService} for IOStrategies
* that require worker threads + * @param workerConfig the config + * @return this builder */ public T setWorkerThreadPoolConfig(final ThreadPoolConfig workerConfig) { this.workerConfig = workerConfig; @@ -157,6 +160,8 @@ public ThreadPoolConfig getSelectorThreadPoolConfig() { * Sets the {@link ThreadPoolConfig} that will be used to construct the * {@link java.util.concurrent.ExecutorService} which will run the {@link NIOTransport}'s * {@link org.glassfish.grizzly.nio.SelectorRunner}s. + * @param kernelConfig the config + * @return this builder */ public T setSelectorThreadPoolConfig(final ThreadPoolConfig kernelConfig) { this.kernelConfig = kernelConfig; @@ -306,6 +311,7 @@ public T setSelectorProvider(SelectorProvider selectorProvider) { /** + * @return the Transport name * @see Transport#getName() */ public String getName() { @@ -314,7 +320,7 @@ public String getName() { /** * @see Transport#setName(String) - * + * @param name the {@link Transport} name * @return thisNIOTransportBuilder
*/ public T setName(String name) { @@ -323,6 +329,8 @@ public T setName(String name) { } /** + * @return the default {@link Processor} if a {@link Connection} + * does not specify a preference * @see Transport#getProcessor() */ public Processor getProcessor() { @@ -330,6 +338,8 @@ public Processor getProcessor() { } /** + * @param processor the default {@link Processor} if a {@link Connection} + * does not specify a preference * @see Transport#setProcessor(Processor) * * @return thisNIOTransportBuilder
@@ -340,7 +350,8 @@ public T setProcessor(Processor processor) { } /** - * @see Transport#getProcessorSelector() () + * @return the default {@link ProcessorSelector} + * @see Transport#getProcessorSelector() */ public ProcessorSelector getProcessorSelector() { return processorSelector; @@ -348,7 +359,7 @@ public ProcessorSelector getProcessorSelector() { /** * @see Transport#setProcessorSelector(ProcessorSelector) - * + * @param processorSelector the default {@link ProcessorSelector} * @return thisNIOTransportBuilder
*/ public T setProcessorSelector(ProcessorSelector processorSelector) { @@ -357,7 +368,8 @@ public T setProcessorSelector(ProcessorSelector processorSelector) { } /** - * @see Transport#getReadBufferSize() () + * @return the default buffer size + * @see Transport#getReadBufferSize() */ public int getReadBufferSize() { return readBufferSize; @@ -365,7 +377,7 @@ public int getReadBufferSize() { /** * @see Transport#setReadBufferSize(int) - * + * @param readBufferSize the new buffer size * @return thisNIOTransportBuilder
*/ public T setReadBufferSize(int readBufferSize) { @@ -374,6 +386,7 @@ public T setReadBufferSize(int readBufferSize) { } /** + * @return the default buffer size * @see Transport#getWriteBufferSize() */ public int getWriteBufferSize() { @@ -382,7 +395,7 @@ public int getWriteBufferSize() { /** * @see Transport#setWriteBufferSize(int) - * + * @param writeBufferSize the new write buffer size * @return thisNIOTransportBuilder
*/ public T setWriteBufferSize(int writeBufferSize) { @@ -391,15 +404,20 @@ public T setWriteBufferSize(int writeBufferSize) { } /** - * @see NIOTransport#getClientSocketSoTimeout() + * @return gets the timeout on socket blocking operations + * on the client + * @see java.net.Socket#getSoTimeout() */ public int getClientSocketSoTimeout() { return clientSocketSoTimeout; } /** + * Sets the timeout on socket blocking operations for the + * client + * @param clientSocketSoTimeout the specified timeout in milliseconds * @return thisNIOTransportBuilder
- * @see NIOTransport#setClientSocketSoTimeout(int) + * @see java.net.Socket#setSoTimeout(int) */ public T setClientSocketSoTimeout(int clientSocketSoTimeout) { this.clientSocketSoTimeout = clientSocketSoTimeout; @@ -407,13 +425,16 @@ public T setClientSocketSoTimeout(int clientSocketSoTimeout) { } /** - * @see NIOTransport#getConnectionTimeout() + * @return value of the connectio timeout in milliseconds + * @see java.net.URLConnection#getConnectTimeout() */ public int getConnectionTimeout() { return connectionTimeout; } /** + * @param connectionTimeout the value of the connection + * timeout in milliseconds * @return thisNIOTransportBuilder
* @see NIOTransport#setConnectionTimeout(int) */ @@ -423,6 +444,8 @@ public T setConnectionTimeout(int connectionTimeout) { } /** + * @param timeUnit the {@link TimeUnit} to convert the result to + * @return the blocking read timeout in the specified {@link TimeUnit} * @see Transport#getReadTimeout(java.util.concurrent.TimeUnit) */ public long getReadTimeout(final TimeUnit timeUnit) { @@ -434,6 +457,10 @@ public long getReadTimeout(final TimeUnit timeUnit) { } /** + * Sets the value of the blocking read timeout + * @param timeout the new timeout value + * @param timeUnit the unit of the new timeout value + * @return this NioTransportBuilder * @see Transport#setReadTimeout(long, java.util.concurrent.TimeUnit) */ public T setReadTimeout(final long timeout, final TimeUnit timeUnit) { @@ -446,6 +473,8 @@ public T setReadTimeout(final long timeout, final TimeUnit timeUnit) { } /** + * @param timeUnit the {@link TimeUnit} to convert the result to + * @return the value of the write timeout * @see Transport#getWriteTimeout(java.util.concurrent.TimeUnit) */ public long getWriteTimeout(final TimeUnit timeUnit) { @@ -457,6 +486,9 @@ public long getWriteTimeout(final TimeUnit timeUnit) { } /** + * @param timeout the new write timeout value + * @param timeUnit the {@link TimeUnit} of the timeout value + * @return this NIOTransportBuilder * @see Transport#setWriteTimeout(long, java.util.concurrent.TimeUnit) */ public T setWriteTimeout(final long timeout, final TimeUnit timeUnit) { @@ -470,15 +502,19 @@ public T setWriteTimeout(final long timeout, final TimeUnit timeUnit) { /** - * @see org.glassfish.grizzly.nio.transport.TCPNIOTransport#isReuseAddress() + * Whether address may be reused for multiple sockets + * @return SO_REUSEADDR + * @see Socket man page */ public boolean isReuseAddress() { return reuseAddress; } /** + * Sets whether address may be reused for multiple sockets + * @param reuseAddress SO_REUSEADDR * @return thisTCPNIOTransportBuilder
- * @see org.glassfish.grizzly.nio.transport.TCPNIOTransport#setReuseAddress(boolean) + * @see Socket man page */ public T setReuseAddress(boolean reuseAddress) { this.reuseAddress = reuseAddress; @@ -486,19 +522,18 @@ public T setReuseAddress(boolean reuseAddress) { } /** + * Max asynchronous write queue size in bytes + * @return the value is per connection, not transport total. * @see org.glassfish.grizzly.asyncqueue.AsyncQueueWriter#getMaxPendingBytesPerConnection() - * - * Note: the value is per connection, not transport total. */ public int getMaxAsyncWriteQueueSizeInBytes() { return maxPendingBytesPerConnection; } /** + * @param maxAsyncWriteQueueSizeInBytes the value is per connection, not transport total. * @return thisTCPNIOTransportBuilder
* @see org.glassfish.grizzly.asyncqueue.AsyncQueueWriter#setMaxPendingBytesPerConnection(int) - * - * Note: the value is per connection, not transport total. */ public T setMaxAsyncWriteQueueSizeInBytes(final int maxAsyncWriteQueueSizeInBytes) { this.maxPendingBytesPerConnection = maxAsyncWriteQueueSizeInBytes; @@ -506,6 +541,7 @@ public T setMaxAsyncWriteQueueSizeInBytes(final int maxAsyncWriteQueueSizeInByte } /** + * @return true, if NIOTransport is configured to use AsyncQueueWriter, optimized to be used in connection multiplexing mode, or false otherwise. * @see org.glassfish.grizzly.nio.NIOTransport#isOptimizedForMultiplexing() */ public boolean isOptimizedForMultiplexing() { @@ -513,6 +549,7 @@ public boolean isOptimizedForMultiplexing() { } /** + * @param optimizedForMultiplexing Configure NIOTransport to be optimized for connection multiplexing * @see org.glassfish.grizzly.nio.NIOTransport#setOptimizedForMultiplexing(boolean) * * @return thisTCPNIOTransportBuilder
@@ -562,7 +599,8 @@ public NIOTransport build() { // ------------------------------------------------------- Protected Methods /** - * See: http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ205 + * @return this NIOTransportBuilder + * @see http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ205 */ protected abstract T getThis(); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/PortRange.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/PortRange.java index c3b305f966..f94dfde2a1 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/PortRange.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/PortRange.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2009, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -35,6 +36,8 @@ public class PortRange { /** * Creates a port range with the given bounds (both inclusive). * + * @param low start of port range + * @param high end of port range * @throws IllegalArgumentException is either bound is not between * 1 and 65535, or ifhigh
is lower than *low
. @@ -49,6 +52,7 @@ public PortRange(final int low, final int high) { /** * Creates a port range containing a single port. + * @param port port */ public PortRange(final int port) { this(port, port); @@ -61,6 +65,7 @@ public PortRange(final int port) { * * The bounds must be between 1 and 65535, both inclusive. * + * @param s either "number" or "number:number" * @return The port range represented bys
. */ public static PortRange valueOf(String s) diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Processor.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Processor.java index 6aed4ded02..dcabdf5280 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Processor.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Processor.java @@ -65,7 +65,7 @@ void write(Connection connection, /** * Is this {@link Processor} interested in processing the i/o event * - * @param ioEvent + * @param ioEvent the event to check if the Processor is interested in * @return true, if this {@link Processor} is interested and execution * process will start, false otherwise. */ diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadHandler.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadHandler.java index 08097a32d7..186fd32acb 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadHandler.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadHandler.java @@ -32,7 +32,7 @@ public interface ReadHandler { * be consumed by the handler implementation before re-registering. * * - * @throws Exception, {@link Exception} might be thrown by the custom + * @throws Exception {@link Exception} might be thrown by the custom * handler code. This exception will be delegated for processing to * {@link #onError(java.lang.Throwable)}. */ @@ -53,7 +53,7 @@ public interface ReadHandler { * Invoked when all data for the current request has been read. * * - * @throws Exception, {@link Exception} might be thrown by the custom + * @throws Exception {@link Exception} might be thrown by the custom * handler code. This exception will be delegated for processing to * {@link #onError(java.lang.Throwable)}. */ diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadResult.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadResult.java index 8b7708a19c..08a7c2c198 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadResult.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/ReadResult.java @@ -194,10 +194,10 @@ public final void setReadSize(int readSize) { /** * One method to set all the WriteResult properties. * - * @param connection - * @param message - * @param srcAddress - * @param readSize + * @param connection the connection the data was read from + * @param message the message which was read + * @param srcAddress the source address the message was read from + * @param readSize number of bytes which were read */ protected void set(final Connectionconnection, final K message, final L srcAddress, final int readSize) { diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Readable.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Readable.java index 3d4e4d8de2..d6820097aa 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Readable.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Readable.java @@ -30,6 +30,7 @@ public interface Readable { /** * Method reads data. + * @param type of data to read * @return {@link Future}, using which it's possible to check the result */ GrizzlyFuture > read(); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketBinder.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketBinder.java index 21f3dd6c6f..8dfa27b294 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketBinder.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketBinder.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2009, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -30,10 +31,10 @@ public interface SocketBinder { /** * Binds Transport to the specific port on localhost. * - * @param port + * @param port the port to bind to * @return bound {@link Connection} * - * @throws java.io.IOException + * @throws java.io.IOException if unable to bind i.e. if port already bound */ Connection> bind(int port) throws IOException; @@ -41,21 +42,21 @@ public interface SocketBinder { * Binds Transport to the specific host and port. * * @param host the local host the server will bind to - * @param port + * @param port specific port to bind to * @return bound {@link Connection} * - * @throws java.io.IOException + * @throws java.io.IOException if unable to bind i.e. if port already bound */ Connection> bind(String host, int port) throws IOException; /** * Binds Transport to the specific host and port. * @param host the local host the server will bind to - * @param port + * @param port the port to bind to * @param backlog the maximum length of the queue * @return bound {@link Connection} * - * @throws java.io.IOException + * @throws java.io.IOException if unable to bind i.e. if port already bound */ Connection> bind(String host, int port, int backlog) throws IOException; @@ -67,7 +68,7 @@ public interface SocketBinder { * @param backlog the maximum length of the queue * @return bound {@link Connection} * - * @throws java.io.IOException + * @throws java.io.IOException if unable to bind i.e. if port already bound */ Connection> bind(String host, PortRange portRange, int backlog) throws IOException; @@ -80,7 +81,7 @@ public interface SocketBinder { * @param backlog the maximum length of the queue * @return bound {@link Connection} * - * @throws java.io.IOException + * @throws java.io.IOException if unable to bind i.e. if port already bound */ Connection> bind(String host, PortRange portRange, boolean randomStartPort, int backlog) throws IOException; @@ -90,7 +91,7 @@ public interface SocketBinder { * @param socketAddress the local address the server will bind to * @return bound {@link Connection} * - * @throws java.io.IOException + * @throws java.io.IOException if unable to bind i.e. if port already bound */ Connection> bind(SocketAddress socketAddress) throws IOException; @@ -101,7 +102,7 @@ public interface SocketBinder { * @param backlog the maximum length of the queue * @return bound {@link Connection} * - * @throws java.io.IOException + * @throws java.io.IOException if unable to bind i.e. if port already bound */ Connection> bind(SocketAddress socketAddress, int backlog) throws IOException; @@ -111,22 +112,19 @@ public interface SocketBinder { * * @return bound {@link Connection} * - * @throws IOException + * @throws IOException if unable to bind i.e. if port already bound */ Connection> bindToInherited() throws IOException; /** * Unbinds bound {@link Transport} connection. * @param connection {@link Connection} - * - * @throws java.io.IOException */ void unbind(Connection> connection); /** * Unbinds all bound {@link Transport} connections. * - * @throws java.io.IOException */ void unbindAll(); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketConnectorHandler.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketConnectorHandler.java index 4f9981d086..679a6300de 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketConnectorHandler.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/SocketConnectorHandler.java @@ -42,7 +42,7 @@ public interface SocketConnectorHandler extends ConnectorHandler * @return {@link Future} of connect operation, which could be used to get * resulting {@link Connection}. * - * @throws java.io.IOException + * @throws java.io.IOException not actually thrown */ Future connect(String host, int port) throws IOException; } diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/StandaloneProcessor.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/StandaloneProcessor.java index a9233781c8..02eb317f27 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/StandaloneProcessor.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/StandaloneProcessor.java @@ -96,6 +96,7 @@ public Context obtainContext(final Connection connection) { * Get the {@link Connection} {@link StreamReader}, to read data from the * {@link Connection}. * + * @param connection {@link Connection} to get the {@link StreamReader} for * @return the {@link Connection} {@link StreamReader}, to read data from the * {@link Connection}. */ @@ -107,6 +108,7 @@ public StreamReader getStreamReader(Connection connection) { * Get the {@link Connection} {@link StreamWriter}, to write data to the * {@link Connection}. * + * @param connection connection to get the {@link StreamWriter} for * @return the {@link Connection} {@link StreamWriter}, to write data to the * {@link Connection}. */ diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/ThreadCache.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/ThreadCache.java index 06e9dc278d..5b65a646c1 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/ThreadCache.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/ThreadCache.java @@ -33,8 +33,7 @@ public final class ThreadCache { private static int indexCounter; - private static final ThreadLocal genericCacheAttr = - new ThreadLocal (); + private static final ThreadLocal genericCacheAttr = new ThreadLocal (); public static synchronized CachedTypeIndex obtainIndex( Class clazz, int size) { @@ -79,7 +78,7 @@ public static boolean putToCache(final Thread currentThread, * Unlike {@link #takeFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object won't be removed from cache. * - * @param + * @param cached object type * @param index the cached object type index. * @return cached object. */ @@ -92,7 +91,7 @@ public static E getFromCache(final CachedTypeIndex index) { * Unlike {@link #takeFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object won't be removed from cache. * - * @param + * @param cached object type * @param currentThread current {@link Thread} * @param index the cached object type index. * @return cached object. @@ -118,7 +117,7 @@ public static E getFromCache(final Thread currentThread, * Unlike {@link #getFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object will be removed from cache. * - * @param + * @param cached object type * @param index the cached object type index * @return cached object */ @@ -131,7 +130,7 @@ public static E takeFromCache(final CachedTypeIndex index) { * Unlike {@link #getFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object will be removed from cache. * - * @param + * @param cached object type * @param currentThread current {@link Thread} * @param index the cached object type index * @return cached object @@ -183,7 +182,7 @@ public boolean put(final CachedTypeIndex index, final Object o) { * Unlike {@link #take(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object won't be removed from cache. * - * @param + * @param cached object type * @param index the cached object type index. * @return cached object. */ @@ -207,7 +206,7 @@ public E get(final CachedTypeIndex index) { * Unlike {@link #get(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object will be removed from cache. * - * @param + * @param cached object type * @param index the cached object type index. * @return cached object. */ diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Transformer.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Transformer.java index 116407105d..9489941b08 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Transformer.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Transformer.java @@ -22,7 +22,7 @@ * Transformer interface, which knows how to transform the original * data to some custom representation. * A Transformer implementation could be stateful or stateless. However - * it's very easy to write stateful Transformer, which actaully doesn't + * it's very easy to write stateful Transformer, which actually doesn't * save any state internally, but uses {@link AttributeStorage} as an external * state storage. Please note, that {@link AttributeStorage} is being passed * as the parameter to all Transformer methods. This way it's @@ -48,9 +48,10 @@ public interface Transformer { * * @param storage the external state storage, where Transformer could * get/put a state. + * @param input data to transform * @return the result {@link TransformationResult} * - * @throws org.glassfish.grizzly.TransformationException + * @throws org.glassfish.grizzly.TransformationException if failed to transport i.e. invalid types */ TransformationResult transform(AttributeStorage storage, K input) throws TransformationException; diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Transport.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Transport.java index b67614fca5..190c2a4dd7 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Transport.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Transport.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -121,6 +122,8 @@ enum State {STARTING, STARTED, PAUSING, PAUSED, STOPPING, STOPPED} * then {@link Transport} will try to get {@link Processor} using * {@link ProcessorSelector#select(IOEvent, Connection)}. * + * @param ioEvent the type of events the Processor should handle + * @param connection connection to obtain Processor for * @return the default {@link Processor}, which will process * {@link Connection} I/O events, if one doesn't have * own {@link Processor} preferences. @@ -382,14 +385,15 @@ enum State {STARTING, STARTED, PAUSING, PAUSED, STOPPING, STOPPED} /** * Starts the transport * - * @throws IOException + * @throws IOException if transport fails to start. This may not occur if Transport + * was not in {@link State#STOPPED}. */ void start() throws IOException; /** * Stops the transport and closes all the connections * - * @throws IOException + * @throws IOException if there was an error shutting down * * @deprecated Use {@link #shutdownNow()}. */ @@ -434,8 +438,8 @@ GrizzlyFuture shutdown(final long gracePeriod, /** * Forcibly stops the transport and closes all connections. * - * @throws IOException - * + * @throws IOException if there was an error shutting down + * @see #shutdown() to complete gracefully * @since 2.3.5 */ void shutdownNow() throws IOException; @@ -529,11 +533,13 @@ void fireIOEvent(IOEvent ioEvent, Connection connection, /** * Get the monitoring configuration for Transport {@link Connection}s. + * @return the configuration */ MonitoringConfig getConnectionMonitoringConfig(); /** * Get the monitoring configuration for Transport thread pool. + * @return the configuration */ MonitoringConfig getThreadPoolMonitoringConfig(); @@ -556,6 +562,7 @@ void fireIOEvent(IOEvent ioEvent, Connection connection, * explicitly set, it will default to {@value #DEFAULT_READ_TIMEOUT} seconds. * * @param timeUnit the {@link TimeUnit} to convert the returned result to. + * @return the value of the read timeout * * @since 2.3 */ @@ -567,7 +574,7 @@ void fireIOEvent(IOEvent ioEvent, Connection connection, * A value of zero or less effectively disables the timeout. * * @param timeout the new timeout value - * @param timeUnit the {@TimeUnit} specification of the provided value. + * @param timeUnit the {@link TimeUnit} specification of the provided value. * * @see Connection#setReadTimeout(long, java.util.concurrent.TimeUnit) * @@ -581,6 +588,7 @@ void fireIOEvent(IOEvent ioEvent, Connection connection, * explicitly set, it will default to {@value #DEFAULT_WRITE_TIMEOUT} seconds. * * @param timeUnit the {@link TimeUnit} to convert the returned result to. + * @return the value of the write timeout * * @since 2.3 */ @@ -592,7 +600,7 @@ void fireIOEvent(IOEvent ioEvent, Connection connection, * A value of zero or less effectively disables the timeout. * * @param timeout the new timeout value - * @param timeUnit the {@TimeUnit} specification of the provided value. + * @param timeUnit the {@link TimeUnit} specification of the provided value. * * @see Connection#setWriteTimeout(long, java.util.concurrent.TimeUnit) * diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/WriteHandler.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/WriteHandler.java index b89e1d6166..eccd93f5c6 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/WriteHandler.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/WriteHandler.java @@ -29,16 +29,15 @@ public interface WriteHandler { * This callback will be invoked when the requirements as dictated * by writer are met. * - * @throws Exception, {@link Exception} might be thrown by the custom + * @throws Exception {@link Exception} might be thrown by the custom * handler code. This exception will be delegated for processing to * {@link #onError(java.lang.Throwable)}. */ void onWritePossible() throws Exception; /** - * * Invoked when an error occurs processing the request asynchronously. - *
+ * @param t cause of error */ void onError(final Throwable t); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Writeable.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Writeable.java index cf232d5f2c..823ec8191e 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Writeable.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Writeable.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ld. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -31,6 +32,7 @@ public interface Writeableextends OutputSink { /** * Method writes the buffer. * + * @param type of data to be written * @param message the buffer, from which the data will be written * @return {@link Future}, using which it's possible to check the * result @@ -40,6 +42,7 @@ public interface Writeable extends OutputSink { /** * Method writes the buffer. * + * @param type of data to be written * @param message the buffer, from which the data will be written * @param completionHandler {@link CompletionHandler}, * which will get notified, when write will be completed @@ -50,6 +53,7 @@ void write(M message, /** * Method writes the buffer. * + * @param type of data to be written * @param message the buffer, from which the data will be written * @param completionHandler {@link CompletionHandler}, * which will get notified, when write will be completed @@ -64,6 +68,7 @@ void write(M message, /** * Method writes the buffer to the specific address. * + * @param type of data to be written * @param dstAddress the destination address the buffer will be * sent to * @param message the buffer, from which the data will be written @@ -77,6 +82,7 @@ void write(L dstAddress, /** * Method writes the buffer to the specific address. * + * @param type of data to be written * @param dstAddress the destination address the buffer will be * sent to * @param message the buffer, from which the data will be written diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/Writer.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/Writer.java index 93a416e744..988c91a330 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/Writer.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/Writer.java @@ -43,6 +43,7 @@ public interface Writer { * @param message the {@link WritableMessage}, from which the data will be written * @return {@link Future}, using which it's possible to check the * result + * @throws java.io.IOException not thrown */ GrizzlyFuture > write(Connection connection, WritableMessage message) throws IOException; @@ -180,7 +181,7 @@ protected Reentrant initialValue() { /** * Returns the maximum number of write() method reentrants a thread is * allowed to made. This is related to possible - * write()->onComplete()->write()->... chain, which may grow infinitely + * write()->onComplete()->write()->... chain, which may grow infinitely * and cause StackOverflow. Using maxWriteReentrants value it's possible * to limit such a chain. * @@ -195,6 +196,7 @@ public static int getMaxReentrants() { * Returns the current write reentrants counter. Might be useful, if * developer wants to use custom notification mechanism, based on on {@link #canWrite(org.glassfish.grizzly.Connection)} * and various write methods. + * @return current reentrants counter */ public static Reentrant getWriteReentrant() { // ThreadLocal otherwise diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/asyncqueue/WritableMessage.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/asyncqueue/WritableMessage.java index 09c7f373eb..10e5019e78 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/asyncqueue/WritableMessage.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/asyncqueue/WritableMessage.java @@ -43,6 +43,7 @@ public interface WritableMessage { /** * Perform message specific actions to release resources held by the * entity backing this WritableMessage
. + * @return true if successfully released */ boolean release(); @@ -51,7 +52,7 @@ public interface WritableMessage { * (for example {@link org.glassfish.grizzly.FileTransfer}), * which is not loaded in memory. * - * False, if the message is + * @return False, if the message is * located in memory (like {@link org.glassfish.grizzly.Buffer}). */ boolean isExternal(); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/filterchain/DefaultFilterChain.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/filterchain/DefaultFilterChain.java index d634ca4ec0..059020a433 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/filterchain/DefaultFilterChain.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/filterchain/DefaultFilterChain.java @@ -106,16 +106,14 @@ public ProcessorResult execute(FilterChainContext ctx) { try { do { - final FilterExecution execution = executeChainPart(ctx, - executor, ctx.getFilterIdx(), end, filtersState); + final FilterExecution execution = executeChainPart(ctx, executor, ctx.getFilterIdx(), end, filtersState); switch (execution.type) { case FilterExecution.TERMINATE_TYPE: return ProcessorResult.createTerminate(); case FilterExecution.REEXECUTE_TYPE: ctx = execution.getContext(); - final int idx = filtersState.peekUnparsedIdx( - ctx.getOperation(), ctx.getStartIdx(), ctx.getEndIdx()); + final int idx = filtersState.peekUnparsedIdx(ctx.getOperation(), ctx.getStartIdx(), ctx.getEndIdx()); if (idx != -1) { // if there is a remainder associated with the connection // rerun the filter chain with the new context right away diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/HeapMemoryManager.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/HeapMemoryManager.java index e450e188ec..e5ae6e3cf9 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/HeapMemoryManager.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/HeapMemoryManager.java @@ -173,6 +173,11 @@ public Buffer wrap(final ByteBuffer byteBuffer) { // ------------------------------------------------------- Protected Methods + /** + * Creates a new HeapBuffer with a a specified size. + * @param size size of buffer created + * @return + */ protected HeapBuffer allocateHeapBuffer(final int size) { if (size > maxBufferSize) { // Don't use pool @@ -294,6 +299,11 @@ private ByteBufferWrapper createByteBufferWrapper( return new RecyclableByteBufferWrapper(underlyingByteBuffer); } + /** + * Gets the thread local buffer pool + * If the pool is not an instance of HeapBufferThreadLocalPool then null is returned + * @return + */ @SuppressWarnings("unchecked") private static HeapBufferThreadLocalPool getHeapBufferThreadLocalPool() { final ThreadLocalPool pool = getThreadLocalPool(); diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/ThreadLocalPool.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/ThreadLocalPool.java index 8c6a1c3d46..0651f55590 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/ThreadLocalPool.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/memory/ThreadLocalPool.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2010, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 Payara Services Ltd. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,28 +17,80 @@ package org.glassfish.grizzly.memory; - /** - * TODO Documentation - * - * @param+ * A thread local pool used by a {@link MemoryManager} + * to create and modify Buffers + * @param Type of Buffer that will be created + * @see java.nio.Buffer + * @see org.glassfish.grizzly.Buffer */ public interface ThreadLocalPool { + + /** + * Resets the Buffer to empty values + * and empties the pool + * @param pool the buffer to reset + */ void reset(E pool); + /** + * Creates a buffer with a given capacity and limit + * @param size maximum number of elements + * @return the new buffer + * @see java.nio.ByteBuffer#allocate(int) + */ E allocate(int size); + /** + * Creates a new Buffer with a set size and assigns it the + * data that was held in the old one as long as the given + * size is not smaller than the data held. + * @param oldBuffer Old Buffer containing data + * @param newSize The size the new Buffer should be. + * @return the new Buffer or null if the buffer could not be resized + */ E reallocate(E oldBuffer, int newSize); + /** + * deallocates the data in the buffer + * @param underlyingBuffer the buffer to release + * @return true if operation successfully completed, false otherwise + */ boolean release(E underlyingBuffer); + /** + * Whether the last element in the buffer has been set + * @param oldBuffer the buffer to check + * @return true if the end of the buffer has been allocated, false otherwise + */ boolean isLastAllocated(E oldBuffer); + /** + * Reduces the buffer to the last data allocated + * @param buffer + * @return the old buffer data that was removed. This may be null. + */ E reduceLastAllocated(E buffer); + /** + * Checks if the size of the Buffer should be reset. + * @param size the desired size of the buffer. If this is less than the current size ofthe buffer + * then this will return false + * @return true if the the buffer should be enlarged to hold the desired size + */ boolean wantReset(int size); + /** + * Gets the number of elements between the current + * position and the limit + * @return number of elements + */ int remaining(); + /** + * Whether there are elements between the current + * position and the end + * @return true if there are unused elements, false otherwise + */ boolean hasRemaining(); } diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/NIOTransport.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/NIOTransport.java index 359f4bdf8c..2385e2ca49 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/NIOTransport.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/NIOTransport.java @@ -385,6 +385,7 @@ protected static void notifyProbesResume(final NIOTransport transport) { * The transport will be started only if its current state is {@link State#STOPPED}, * otherwise the call will be ignored without exception thrown and the transport * state will remain the same as it was before the method call. + * @throws java.io.IOException if an attempt was made to actually start which failed */ @Override public void start() throws IOException { diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLBaseFilter.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLBaseFilter.java index d550352328..209ce0c3b2 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLBaseFilter.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLBaseFilter.java @@ -461,102 +461,7 @@ protected Buffer wrapAll(final FilterChainContext ctx, return output; } -// protected Buffer doHandshakeStep1(final SSLConnectionContext sslCtx, -// final FilterChainContext ctx, -// Buffer inputBuffer) -// throws IOException { -// -// final SSLEngine sslEngine = sslCtx.getSslEngine(); -// final Connection connection = ctx.getConnection(); -// -// final boolean isLoggingFinest = LOGGER.isLoggable(Level.FINEST); -// try { -// HandshakeStatus handshakeStatus = sslEngine.getHandshakeStatus(); -// -// while (true) { -// -// if (isLoggingFinest) { -// LOGGER.log(Level.FINEST, "Loop Engine: {0} handshakeStatus={1}", -// new Object[]{sslEngine, sslEngine.getHandshakeStatus()}); -// } -// -// switch (handshakeStatus) { -// case NEED_UNWRAP: { -// -// if (isLoggingFinest) { -// LOGGER.log(Level.FINEST, "NEED_UNWRAP Engine: {0}", sslEngine); -// } -// -// if (inputBuffer == null || !inputBuffer.hasRemaining()) { -// return inputBuffer; -// } -// -// final int expectedLength = getSSLPacketSize(inputBuffer); -// if (expectedLength == -1 -// || inputBuffer.remaining() < expectedLength) { -// return inputBuffer; -// } -// -// final SSLEngineResult sslEngineResult = -// handshakeUnwrap(connection, sslCtx, inputBuffer, null); -// -// inputBuffer.shrink(); -// -// final SSLEngineResult.Status status = sslEngineResult.getStatus(); -// -// if (status == SSLEngineResult.Status.BUFFER_UNDERFLOW || -// status == SSLEngineResult.Status.BUFFER_OVERFLOW) { -// throw new SSLException("SSL unwrap error: " + status); -// } -// -// handshakeStatus = sslEngine.getHandshakeStatus(); -// break; -// } -// -// case NEED_WRAP: { -// if (isLoggingFinest) { -// LOGGER.log(Level.FINEST, "NEED_WRAP Engine: {0}", sslEngine); -// } -// -// inputBuffer = makeInputRemainder(sslCtx, ctx, inputBuffer); -// final Buffer buffer = handshakeWrap(connection, sslCtx, null); -// -// try { -// ctx.write(buffer); -// -// handshakeStatus = sslEngine.getHandshakeStatus(); -// } catch (Exception e) { -// buffer.dispose(); -// throw new IOException("Unexpected exception", e); -// } -// -// break; -// } -// -// case NEED_TASK: { -// if (isLoggingFinest) { -// LOGGER.log(Level.FINEST, "NEED_TASK Engine: {0}", sslEngine); -// } -// executeDelegatedTask(sslEngine); -// handshakeStatus = sslEngine.getHandshakeStatus(); -// break; -// } -// -// case FINISHED: -// case NOT_HANDSHAKING: { -// return inputBuffer; -// } -// } -// -// if (handshakeStatus == HandshakeStatus.FINISHED) { -// return inputBuffer; -// } -// } -// } catch (IOException ioe) { -// notifyHandshakeFailed(connection, ioe); -// throw ioe; -// } -// } + protected Buffer doHandshakeSync(final SSLConnectionContext sslCtx, final FilterChainContext ctx,