Skip to content

Commit

Permalink
Fix minor issues identified by IntelliJ
Browse files Browse the repository at this point in the history
- lack of curly braces
- call of default toString() implementation
- redundant semicolon
- etc

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/5106/
  • Loading branch information
Gerd Behrmann committed Jan 18, 2013
1 parent 73bfa59 commit f5f81e6
Show file tree
Hide file tree
Showing 40 changed files with 176 additions and 76 deletions.
@@ -1,5 +1,7 @@
package dmg.cells.applets.login ;

import com.google.common.base.Objects;

import java.io.* ;

public class DomainObjectFrame implements Serializable {
Expand Down Expand Up @@ -35,4 +37,15 @@ public boolean equals( Object obj ){
}
return ((DomainObjectFrame)obj)._id == _id ;
}

@Override
public String toString()
{
return Objects.toStringHelper(this)
.add("payload", _payload)
.add("destination", _destination)
.add("id", _id)
.add("subId", _subId)
.toString();
}
}
Expand Up @@ -101,7 +101,7 @@ public void setCore( CellCommandTaskCore core ){
_session = core ;
}
public String toString(){
return _clientKey+" = "+( _session == null ? "not attached" : _session.toString() ) ;
return _clientKey+" = "+( _session == null ? "not attached" : _session.getName() ) ;
}
public String getClientKey(){
return _clientKey ;
Expand Down
Expand Up @@ -301,7 +301,7 @@ private synchronized Entry unregister( CellPath destination , String eventClass
}


Map<String, Entry> map2 = _destinationMap.get(core);;
Map<String, Entry> map2 = _destinationMap.get(core);
if( map2 == null ) {
throw new
NoSuchElementException("PANIC : inconsitent db : " + core + "/" + eventClass);
Expand Down
Expand Up @@ -80,8 +80,8 @@ public String toString(){
sb.append(" Path : ")
.append(_path == null ? "<none>" : _path.toString())
.append("\n");
for (Object key : _clients.keySet()) {
Object value = _clients.get(key);
for (CellPath key : _clients.keySet()) {
Client value = _clients.get(key);
sb.append(" ").append(key.toString()).append("=")
.append(value.toString()).append("\n");
}
Expand Down
Expand Up @@ -34,6 +34,7 @@ public void close( int flags ) throws CdbLockException {
protected void finalize() throws Throwable {
// System.out.println( "Decrementing "+_name ) ;
_container.unlinkElement( _name ) ;
super.finalize();
}

}
Expand Up @@ -62,6 +62,7 @@ public void remove(){
protected void finalize() throws Throwable {
System.out.println( "Decrementing "+_name ) ;
_creator.unlinkResource( this ) ;
super.finalize();
}
public String toString(){
StringBuilder sb = new StringBuilder() ;
Expand Down
1 change: 1 addition & 0 deletions modules/cells/src/main/java/dmg/util/db/XClass.java
Expand Up @@ -15,6 +15,7 @@ protected void finalize() throws Throwable {
synchronized( __lock ){ __counter -- ;
System.out.println( "Finalizing ("+__counter+") : " + _name ) ;
}
super.finalize();
}
public String toString(){ return _name ; }
}
Expand Up @@ -2568,8 +2568,9 @@ void setACL(Connection dbConnection, FsInode inode, List<ACE> acl) throws SQLExc
stDeleteACL.setString(1, inode.toString());
stDeleteACL.executeUpdate();

if(acl.isEmpty())
if(acl.isEmpty()) {
return;
}
stAddACL = dbConnection.prepareStatement(sqlAddACL);

int order = 0;
Expand Down
Expand Up @@ -19,8 +19,9 @@ public static void main(String[] args) throws Exception {
FsInode inode = fs.path2inode(args[FsFactory.ARGC]);
String checksum = fs
.getInodeChecksum(inode, ChecksumType.ADLER32.getType());
if (checksum == null)
if (checksum == null) {
checksum = "N.A.";
}
System.out.println(checksum);
}

Expand Down
Expand Up @@ -2653,7 +2653,7 @@ public void messageArrived(CellMessage msg)

((IoHandler)handler).doorTransferArrived( (DoorTransferFinishedMessage)reply ) ;

}else if( reply instanceof PoolMgrGetPoolMsg ){
}else if( reply instanceof PoolMgrSelectPoolMsg ){

((IoHandler)handler).poolMgrSelectPoolArrived( (PoolMgrSelectPoolMsg)reply ) ;

Expand Down
Expand Up @@ -153,7 +153,7 @@ private synchronized void closeNow()
{
if (_ssc != null) {
try {
say("Closing " + _ssc);
say("Closing " + _ssc.socket());
_ssc.close();
} catch (IOException e) {
esay("Failed to close server socket: " + e.getMessage());
Expand Down Expand Up @@ -384,14 +384,14 @@ public void close()
}

try {
say("Closing " + _scs);
say("Closing " + _scs.socket());
_scs.close();
} catch (IOException ie) {
esay("Error closing channel " + _scs + ": " + ie);
}

try {
say("Closing " + _sct);
say("Closing " + _sct.socket());
_sct.close();
} catch (IOException ie) {
esay("Error closing channel " + _sct + ": " + ie);
Expand Down Expand Up @@ -472,7 +472,7 @@ private void processOutput(SocketChannel sct) throws IOException
}

public String toString() {
return _scs.toString() + "<->" + _sct.toString();
return _scs.socket().toString() + "<->" + _sct.socket().toString();
}

} // class Tunnel
Expand Down Expand Up @@ -539,7 +539,7 @@ public void run()
private void accept(SelectionKey key) throws IOException {
ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
SocketChannel sc = ssc.accept();
say("New connection: " + sc);
say("New connection: " + sc.socket());
addPending(sc);
}

Expand All @@ -553,11 +553,11 @@ private void finishConnection(SelectionKey key) throws IOException {
boolean success = sc.finishConnect();

if (success) {
say("New connection: " + sc);
say("New connection: " + sc.socket());
tnl.register(_selector);
} else {
// An error occurred; handle it
esay("Connection error: " + sc);
esay("Connection error: " + sc.socket());
tnl.close();
}
}
Expand Down
Expand Up @@ -61,9 +61,10 @@ public FTPTransactionLog(String root)
}

@Override
public synchronized void finalize()
{
public synchronized void finalize() throws Throwable
{
error("Transaction abandoned");
super.finalize();
}

private synchronized void addLine(String line)
Expand Down
Expand Up @@ -4,7 +4,7 @@
import java.util.HashMap;
import java.util.Map;

class PoolCore implements Serializable {
abstract class PoolCore implements Serializable {
private static final long serialVersionUID = -8571296485927073985L;
protected final String _name;
protected final Map<String, Link> _linkList = new HashMap<>();
Expand Down
Expand Up @@ -2522,7 +2522,7 @@ public void runit() throws Exception {
newPoolSet = new HashSet<>(poolList);
oldPoolSet = new HashSet<>(_knownPoolSet);

for (Object inext : poolList) {
for (String inext : poolList) {
if (oldPoolSet
.contains(inext)) { // remove common part from both sets
oldPoolSet.remove(inext);
Expand Down
Expand Up @@ -1059,7 +1059,7 @@ private void prepareDailyHtmlFiles( Calendar calendar ){
html.setHeader(header);
while( classEntries.hasNext() ){

Map.Entry<String, long[]> classEntry = classEntries.next();;
Map.Entry<String, long[]> classEntry = classEntries.next();

String className = classEntry.getKey() ;

Expand Down Expand Up @@ -1118,7 +1118,7 @@ private void prepareDailyHtmlFiles( Calendar calendar ){
entries = classMap2.entrySet().iterator() ;
while( entries.hasNext() ){

Map.Entry<String, Map<String, long[]>> entry = entries.next();;
Map.Entry<String, Map<String, long[]>> entry = entries.next();

String className = entry.getKey() ;

Expand Down
Expand Up @@ -410,7 +410,7 @@ private void removePattern( String groupClass , String group , String patternNam
toBeRemoved.add(poolName);
}
}
for (Object o : toBeRemoved) {
for (String o : toBeRemoved) {
tableMap.remove(o);
}

Expand Down
6 changes: 4 additions & 2 deletions modules/dcache/src/main/java/diskCacheV111/util/PnfsId.java
Expand Up @@ -2,8 +2,11 @@

package diskCacheV111.util;

import com.google.common.base.Strings;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -69,8 +72,7 @@ public boolean equals(Object o) {

PnfsId other = (PnfsId) o;
return Arrays.equals(_a, other._a)
&& (_domain == other._domain
|| (_domain != null && _domain.equals(other._domain)));
&& Objects.equals(_domain, other._domain);
}

@Override
Expand Down
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;
import java.util.Set;

import com.google.common.base.Objects;
import diskCacheV111.poolManager.PoolSelectionUnit.SelectionLinkGroup;

public class PoolLinkGroupInfo implements Serializable {
Expand Down Expand Up @@ -110,6 +111,21 @@ public boolean isNearlineAllowed() {
return _nearlineAllowed;
}

@Override
public String toString()
{
return Objects.toStringHelper(this)
.add("groupName", _groupName)
.add("totalSpace", _totalSpaceInBytes)
.add("availableSpace", _availableSpaceInBytes)
.add("custodial", _custodialAllowed)
.add("replica", _replicaAllowed)
.add("output", _outputAllowed)
.add("nearline", _nearlineAllowed)
.add("online", _onlineAllowed)
.add("attributes", _attributes)
.toString();
}
}
/*
* $Log: not supported by cvs2svn $
Expand Down
Expand Up @@ -3,6 +3,8 @@
*/
package diskCacheV111.vehicles;

import com.google.common.base.Joiner;

public class PoolMgrGetPoolLinkGroups extends PoolManagerMessage {

private static final long serialVersionUID = -1855943765961354388L;
Expand All @@ -14,11 +16,7 @@ public PoolMgrGetPoolLinkGroups() {

public String toString() {
if (getReturnCode() == 0 && _poolLinkGroupInfos != null) {
StringBuilder sb = new StringBuilder();
for (PoolLinkGroupInfo info : _poolLinkGroupInfos) {
sb.append('[').append(info).append(']');
}
return sb.toString();
return "[" + Joiner.on(",").join(_poolLinkGroupInfos) + "]";
} else {
return super.toString();
}
Expand Down
Expand Up @@ -14,5 +14,5 @@ public enum Action
/**
* The door should fail the request.
*/
FAIL;
FAIL
}
Expand Up @@ -20,5 +20,5 @@ public enum Result
/**
* The plugin does not suggest what the door should do.
*/
DEFER;
DEFER
}
Expand Up @@ -77,15 +77,17 @@ public AccessType canDeleteFile(Subject subject,
Permission permissionParent = getPermission(subject, parentAttr);
AccessType ofParent = valueOf(AclNFSv4Matcher.isAllowed(permissionParent,
DELETE_CHILD));
if ( ofParent == ACCESS_ALLOWED )
if ( ofParent == ACCESS_ALLOWED ) {
return ofParent;
}

Permission permissionChild = getPermission(subject, childAttr);
AccessType ofChild = valueOf(AclNFSv4Matcher.isAllowed(permissionChild,
DELETE));

if (ofChild == ACCESS_ALLOWED)
if (ofChild == ACCESS_ALLOWED) {
return ofChild;
}

if (ofParent == ACCESS_DENIED
|| ofChild == ACCESS_DENIED) {
Expand Down Expand Up @@ -131,12 +133,14 @@ public AccessType canRename(Subject subject,
Boolean ofSrcParent = AclNFSv4Matcher.isAllowed(permission1, DELETE_CHILD);
Boolean ofDestParent = AclNFSv4Matcher.isAllowed(permission2, ADD_FILE);

if (ofDestParent == ofSrcParent)
if (ofDestParent == ofSrcParent) {
return valueOf(ofSrcParent);
}

if (valueOf(ofSrcParent) == ACCESS_DENIED ||
valueOf(ofDestParent) == ACCESS_DENIED)
valueOf(ofDestParent) == ACCESS_DENIED) {
return ACCESS_DENIED;
}

return ACCESS_UNDEFINED;
}
Expand Down
Expand Up @@ -102,7 +102,7 @@ public class HsmStorageHandler2
//
// the generic part
//
public class Info
public class Info
{
private final List<CacheFileAvailable> _callbacks = new ArrayList();
private final PnfsId _pnfsId;
Expand Down
Expand Up @@ -139,9 +139,7 @@ public String ac_st_ls( Args args )
{
StringBuilder sb = new StringBuilder() ;
for (PnfsId pnfsId : _storageHandler.getStorePnfsIds()) {
_log.debug("ok "+pnfsId);
HsmStorageHandler2.Info info = _storageHandler.getStoreInfoByPnfsId(pnfsId) ;
_log.debug("done "+info);
if( info == null ){
sb.append(pnfsId).append(" <zombie>\n") ;
}else{
Expand Down
Expand Up @@ -232,9 +232,10 @@ private Serializable list()
if (args.hasOption("binary")) {
Object [] result = new Object[map.size()];
for (int i = 0; e2.hasNext(); i++) {
String key = e2.next();
Object[] ex = new Object[2];
ex[0] = e2.next();
ex[1] = map.get(ex[0]);
ex[0] = key;
ex[1] = map.get(key);
result[i] = ex;
}
return result;
Expand Down
Expand Up @@ -52,7 +52,7 @@ public final StoredMap<String, CacheRepositoryEntryState> getStateMap()

public void toYaml(PrintWriter out, PrintWriter error)
{
for (Object id : getStateMap().keySet()) {
for (String id : getStateMap().keySet()) {
try {
CacheRepositoryEntryState state =
getStateMap().get(id);
Expand Down

0 comments on commit f5f81e6

Please sign in to comment.