From 26732f2fdd4720deee653ab96cd453ed65dcaa87 Mon Sep 17 00:00:00 2001 From: Vlad Dumitrescu Date: Thu, 13 Nov 2014 10:28:08 +0100 Subject: [jinterface] cleanup code according to new style --- .../ericsson/otp/erlang/OtpCookedConnection.java | 190 ++++++++++----------- 1 file changed, 95 insertions(+), 95 deletions(-) (limited to 'lib/jinterface/java_src/com/ericsson/otp/erlang/OtpCookedConnection.java') diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpCookedConnection.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpCookedConnection.java index 43b0cad222..4d80f61d52 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpCookedConnection.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpCookedConnection.java @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * + * * Copyright Ericsson AB 2000-2009. All Rights Reserved. - * + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ package com.ericsson.otp.erlang; @@ -27,29 +27,29 @@ import java.net.Socket; * node. The object maintains connection state and allows data to be sent to and * received from the peer. *

- * + * *

* Once a connection is established between the local node and a remote node, * the connection object can be used to send and receive messages between the * nodes. *

- * + * *

* The various receive methods are all blocking and will return only when a * valid message has been received or an exception is raised. *

- * + * *

* If an exception occurs in any of the methods in this class, the connection * will be closed and must be reopened in order to resume communication with the * peer. *

- * + * *

* The message delivery methods in this class deliver directly to * {@link OtpMbox mailboxes} in the {@link OtpNode OtpNode} class. *

- * + * *

* It is not possible to create an instance of this class directly. * OtpCookedConnection objects are created as needed by the underlying mailbox @@ -70,45 +70,45 @@ public class OtpCookedConnection extends AbstractConnection { * OtpSelf#accept() OtpSelf.accept()} to create a connection based on data * received when handshaking with the peer node, when the remote node is the * connection intitiator. - * + * * @exception java.io.IOException if it was not possible to connect to the * peer. - * + * * @exception OtpAuthException if handshake resulted in an authentication * error */ // package scope OtpCookedConnection(final OtpNode self, final Socket s) throws IOException, - OtpAuthException { - super(self, s); - this.self = self; - links = new Links(25); - start(); + OtpAuthException { + super(self, s); + this.self = self; + links = new Links(25); + start(); } /* * Intiate and open a connection to a remote node. - * + * * @exception java.io.IOException if it was not possible to connect to the * peer. - * + * * @exception OtpAuthException if handshake resulted in an authentication * error. */ // package scope OtpCookedConnection(final OtpNode self, final OtpPeer other) - throws IOException, OtpAuthException { - super(self, other); - this.self = self; - links = new Links(25); - start(); + throws IOException, OtpAuthException { + super(self, other); + this.self = self; + links = new Links(25); + start(); } // pass the error to the node @Override public void deliver(final Exception e) { - self.deliverError(this, e); - return; + self.deliverError(this, e); + return; } /* @@ -118,32 +118,32 @@ public class OtpCookedConnection extends AbstractConnection { */ @Override public void deliver(final OtpMsg msg) { - final boolean delivered = self.deliver(msg); - - switch (msg.type()) { - case OtpMsg.linkTag: - if (delivered) { - links.addLink(msg.getRecipientPid(), msg.getSenderPid()); - } else { - try { - // no such pid - send exit to sender - super.sendExit(msg.getRecipientPid(), msg.getSenderPid(), - new OtpErlangAtom("noproc")); - } catch (final IOException e) { - } - } - break; - - case OtpMsg.unlinkTag: - case OtpMsg.exitTag: - links.removeLink(msg.getRecipientPid(), msg.getSenderPid()); - break; - - case OtpMsg.exit2Tag: - break; - } - - return; + final boolean delivered = self.deliver(msg); + + switch (msg.type()) { + case OtpMsg.linkTag: + if (delivered) { + links.addLink(msg.getRecipientPid(), msg.getSenderPid()); + } else { + try { + // no such pid - send exit to sender + super.sendExit(msg.getRecipientPid(), msg.getSenderPid(), + new OtpErlangAtom("noproc")); + } catch (final IOException e) { + } + } + break; + + case OtpMsg.unlinkTag: + case OtpMsg.exitTag: + links.removeLink(msg.getRecipientPid(), msg.getSenderPid()); + break; + + case OtpMsg.exit2Tag: + break; + } + + return; } /* @@ -151,9 +151,9 @@ public class OtpCookedConnection extends AbstractConnection { */ @SuppressWarnings("resource") void send(final OtpErlangPid from, final OtpErlangPid dest, - final OtpErlangObject msg) throws IOException { - // encode and send the message - sendBuf(from, dest, new OtpOutputStream(msg)); + final OtpErlangObject msg) throws IOException { + // encode and send the message + sendBuf(from, dest, new OtpOutputStream(msg)); } /* @@ -162,66 +162,66 @@ public class OtpCookedConnection extends AbstractConnection { */ @SuppressWarnings("resource") void send(final OtpErlangPid from, final String dest, - final OtpErlangObject msg) throws IOException { - // encode and send the message - sendBuf(from, dest, new OtpOutputStream(msg)); + final OtpErlangObject msg) throws IOException { + // encode and send the message + sendBuf(from, dest, new OtpOutputStream(msg)); } @Override public void close() { - super.close(); - breakLinks(); + super.close(); + breakLinks(); } @Override protected void finalize() { - close(); + close(); } /* * this one called by dying/killed process */ void exit(final OtpErlangPid from, final OtpErlangPid to, - final OtpErlangObject reason) { - try { - super.sendExit(from, to, reason); - } catch (final Exception e) { - } + final OtpErlangObject reason) { + try { + super.sendExit(from, to, reason); + } catch (final Exception e) { + } } /* * this one called explicitely by user code => use exit2 */ void exit2(final OtpErlangPid from, final OtpErlangPid to, - final OtpErlangObject reason) { - try { - super.sendExit2(from, to, reason); - } catch (final Exception e) { - } + final OtpErlangObject reason) { + try { + super.sendExit2(from, to, reason); + } catch (final Exception e) { + } } /* * snoop for outgoing links and update own table */ synchronized void link(final OtpErlangPid from, final OtpErlangPid to) - throws OtpErlangExit { - try { - super.sendLink(from, to); - links.addLink(from, to); - } catch (final IOException e) { - throw new OtpErlangExit("noproc", to); - } + throws OtpErlangExit { + try { + super.sendLink(from, to); + links.addLink(from, to); + } catch (final IOException e) { + throw new OtpErlangExit("noproc", to); + } } /* * snoop for outgoing unlinks and update own table */ synchronized void unlink(final OtpErlangPid from, final OtpErlangPid to) { - links.removeLink(from, to); - try { - super.sendUnlink(from, to); - } catch (final IOException e) { - } + links.removeLink(from, to); + try { + super.sendUnlink(from, to); + } catch (final IOException e) { + } } /* @@ -229,18 +229,18 @@ public class OtpCookedConnection extends AbstractConnection { * through this connection */ synchronized void breakLinks() { - if (links != null) { - final Link[] l = links.clearLinks(); - - if (l != null) { - final int len = l.length; - - for (int i = 0; i < len; i++) { - // send exit "from" remote pids to local ones - self.deliver(new OtpMsg(OtpMsg.exitTag, l[i].remote(), l[i] - .local(), new OtpErlangAtom("noconnection"))); - } - } - } + if (links != null) { + final Link[] l = links.clearLinks(); + + if (l != null) { + final int len = l.length; + + for (int i = 0; i < len; i++) { + // send exit "from" remote pids to local ones + self.deliver(new OtpMsg(OtpMsg.exitTag, l[i].remote(), l[i] + .local(), new OtpErlangAtom("noconnection"))); + } + } + } } } -- cgit v1.2.3