package br.odb.multiplayer.model;

import java.util.HashMap;

import javax.servlet.ServletContext;

public class ServerContext {
	public final HashMap<Integer, Game> games = new HashMap<Integer, Game>();
	public final HashMap< String, Game > gameBuilders = new HashMap< String, Game >();

	public ServerContext() {
	}

	public static ServerContext createOrRetrieve( ServletContext servletContext) {

		ServerContext context = (ServerContext) servletContext
				.getAttribute("games-context");

		if (context == null) {
			reset( servletContext );
		}

		return context;
	}

	public static void reset(ServletContext servletContext) {
		servletContext.setAttribute("games-context", new ServerContext() );
	}
}

package br.odb.multiplayer.model;

import java.util.HashMap;

import javax.servlet.ServletContext;

public class ServerContext {
	public final HashMap<Integer, Game> games = new HashMap<Integer, Game>();
	public final HashMap< String, Game > gameBuilders = new HashMap< String, Game >();

	public ServerContext() {
	}

	public static ServerContext createOrRetrieve( ServletContext servletContext) {

		ServerContext context = (ServerContext) servletContext
				.getAttribute("games-context");

		if (context == null) {
			reset( servletContext );

			context = (ServerContext) servletContext.getAttribute("games-context");
		}

		return context;
	}

	public static void reset(ServletContext servletContext) {
		servletContext.setAttribute("games-context", new ServerContext() );
	}
}

Fix idiotic bug in GetGameId


package nl.opengeogroep.safetymaps.server.stripes;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.action.UrlBinding;

/**
 *
 * @author matthijsln
 */
@UrlBinding("/viewer/api/login")
public class LoginActionBean implements ActionBean {
    private ActionBeanContext context;

    @Override
    public ActionBeanContext getContext() {
        return context;
    }

    @Override
    public void setContext(ActionBeanContext context) {
        this.context = context;
    }

    public Resolution redirect() {
        return new StreamingResolution("text/html",
            "" +
                "<meta http-equiv=\"refresh\" content=\"0;url=" + context.getRequest().getContextPath() + "/viewer/\">" +
            ""
        );
    }
}

package nl.opengeogroep.safetymaps.server.stripes;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.action.UrlBinding;

/**
 *
 * @author matthijsln
 */
@UrlBinding("/viewer/api/login")
public class LoginActionBean implements ActionBean {
    private ActionBeanContext context;

    @Override
    public ActionBeanContext getContext() {
        return context;
    }

    @Override
    public void setContext(ActionBeanContext context) {
        this.context = context;
    }

    public Resolution redirect() {
        String returnTo = request.getParameter("returnTo");

        if (returnTo == null || returnTo.length() == 0) {
            returnTo = "/viewer/";
        }

        return new StreamingResolution("text/html",
            "" +
                "<meta http-equiv=\"refresh\" content=\"0;url=" + context.getRequest().getContextPath() + returnTo + "\">" +
            ""
        );
    }
}

Add returnTo param to normal login request


/*******************************************************************************
 * Copyright (c) 2005 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/
package org.eclipse.birt.report.viewer.utilities;

/** A class used to get a workspace classpath
 *
 */
public class WorkspaceClasspathManager
{

	public static final String PROPERTYSEPARATOR = ";";

	private static IWorkspaceClasspathFinder finder;

	public static String getClassPath( )
	{
		if ( finder == null )
			return null;

		return finder.getClassPath( );
	}

	public static void registerClassPathFinder(
			IWorkspaceClasspathFinder pathfinder )
	{
		finder = pathfinder;
	}
}

/*******************************************************************************
 * Copyright (c) 2005 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/
package org.eclipse.birt.report.viewer.utilities;

/** A class used to get a workspace classpath
 *
 */
public class WorkspaceClasspathManager
{

	private static IWorkspaceClasspathFinder finder;

	public static String getClassPath( )
	{
		if ( finder == null )
			return null;

		return finder.getClassPath( );
	}

	public static void registerClassPathFinder(
			IWorkspaceClasspathFinder pathfinder )
	{
		finder = pathfinder;
	}
}

Fix 188486 -- remove hard code for the property separator as ';'.


package co.uk.real_logic.aeron.tools;

import org.apache.commons.cli.ParseException;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import uk.co.real_logic.aeron.tools.PubSubOptions;

/**
 * Created by bhorst on 3/3/15.
 */
public class PubSubOptionsTest
{
    PubSubOptions opts;
    @Before
    public void SetUp() {
        opts = new PubSubOptions();
    }

    @Test
    public void threadsShorthandValid() throws Exception {
        String[] args = { "-t", "1234" };
        opts.parseArgs(args);
        assertThat(opts.getThreads(), is(1234L));
    }

    @Test
    public void threadsLonghandValid() throws Exception {
        String[] args = { "--threads", "1234" };
        opts.parseArgs(args);
        assertThat(opts.getThreads(), is(1234L));
    }

    @Test (expected=ParseException.class)
    public void threadsInvalid() {

    }

    @Test (expected=ParseException.class)
    public void threadsLonghandInvalid() throws Exception {
        String[] args = { "--threads", "asdf" };
        opts.parseArgs(args);
    }
}

package co.uk.real_logic.aeron.tools;

import org.apache.commons.cli.ParseException;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import uk.co.real_logic.aeron.tools.PubSubOptions;

/**
 * Created by bhorst on 3/3/15.
 */
public class PubSubOptionsTest
{
    PubSubOptions opts;
    @Before
    public void setUp()
    {
        opts = new PubSubOptions();
    }

    @Test
    public void threadsShorthandValid() throws Exception
    {
        String[] args = { "-t", "1234" };
        opts.parseArgs(args);
        assertThat(opts.getThreads(), is(1234L));
    }

    @Test
    public void threadsLonghandValid() throws Exception
    {
        String[] args = { "--threads", "1234" };
        opts.parseArgs(args);
        assertThat(opts.getThreads(), is(1234L));
    }

    @Test (expected=ParseException.class)
    public void threadsInvalid() throws Exception
    {
        String[] args = { "-t", "asdf" };
        opts.parseArgs(args);
    }

    @Test (expected=ParseException.class)
    public void threadsLonghandInvalid() throws Exception
    {
        String[] args = { "--threads", "asdf" };
        opts.parseArgs(args);
    }
}

Fix the syntax of unit tests


package net.sourceforge.javydreamercsw.validation.manager.web.file;

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;

/**
 *
 * @author Javier A. Ortiz Bultron <javier.ortiz.78@gmail.com>
 */
public abstract class AbstractFileDisplay implements IFileDisplay {

    @Override
    public boolean supportFile(File f) {
        return f.isFile() && supportFile(f.getName());
    }

    @Override
    public File loadFile(String name, byte[] bytes) throws IOException {
        File result = new File(System.getProperty("java.io.tmpdir")
                + System.getProperty("file.separator") + name);
        FileUtils.writeByteArrayToFile(result, bytes);
        return result;
    }
}

package net.sourceforge.javydreamercsw.validation.manager.web.file;

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;

/**
 *
 * @author Javier A. Ortiz Bultron <javier.ortiz.78@gmail.com>
 */
public abstract class AbstractFileDisplay implements IFileDisplay {

    @Override
    public boolean supportFile(File f) {
        return supportFile(f.getName());
    }

    @Override
    public File loadFile(String name, byte[] bytes) throws IOException {
        File result = new File(System.getProperty("java.io.tmpdir")
                + System.getProperty("file.separator") + name);
        FileUtils.writeByteArrayToFile(result, bytes);
        return result;
    }
}

Fix bug when deciding if file is supported.


package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create;

import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Created by Winston on 21/02/15.
 */
public class CreateIndexURLIndexStore implements SQLUpdate {

    public static final String CREATE_INDEX_URL_INDEX_STORE = "CREATE INDEX `project_path_index` ON `url_index_store`(`project_name`, `path`);\n";

    @Override
    public String getSQL() {
        return CREATE_INDEX_URL_INDEX_STORE;
    }

    @Override
    public void addParametersToStatement(PreparedStatement statement) throws SQLException {

    }

}

package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create;

import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Created by Winston on 21/02/15.
 */
public class CreateIndexURLIndexStore implements SQLUpdate {

    public static final String CREATE_INDEX_URL_INDEX_STORE =
            "CREATE INDEX IF NOT EXISTS `project_path_index` ON `url_index_store`(`project_name`, `path`);\n";

    @Override
    public String getSQL() {
        return CREATE_INDEX_URL_INDEX_STORE;
    }

    @Override
    public void addParametersToStatement(PreparedStatement statement) throws SQLException {

    }

}

Add IF NOT EXISTS to index creation sql statement.


package es.ucm.fdi.tp.views.swing;

public class MessagesBox extends ScrollableTextarea {

	private static final long serialVersionUID = 768586332299945974L;

	public MessagesBox() {
		super();
	}

	public MessagesBox(String text) {
		super(text);
	}

	public MessagesBox(int rows, int cols) {
		super(rows,cols);
	}

	public MessagesBox(String text, int rows, int cols) {
		super(text,rows,cols);
	}

	@Override
	protected void formatTextArea() {
		super.formatTextArea();
		this.textarea.setEditable(false);
		this.textarea.setHighlighter(null);
	}

	/**
	 * @throws UnsupportedOperationException when editable is set to true.
	 */
	@Override
	public void setEditable(boolean b) {
		if(b) throw new UnsupportedOperationException(
				"This textarea object is read-only to users. ");
		else this.textarea.setEditable(false);
	}

	/**
	 * Adds a new message to the box list. Does nothing if the model is null or
	 * the string is null or empty.
	 */
	@Override
	public void append(String str) {
		textarea.append("* " + str + "\n");
	}
}

package es.ucm.fdi.tp.views.swing;

import javax.swing.border.TitledBorder;

public class MessagesBox extends ScrollableTextarea {

	private static final long serialVersionUID = 768586332299945974L;

	public MessagesBox() {
		super();
	}

	public MessagesBox(String text) {
		super(text);
	}

	public MessagesBox(int rows, int cols) {
		super(rows,cols);
	}

	public MessagesBox(String text, int rows, int cols) {
		super(text,rows,cols);
	}

	@Override
	protected void formatTextArea() {
		super.formatTextArea();
		this.textarea.setEditable(false);
		this.textarea.setHighlighter(null);
		this.setBorder(new TitledBorder("Status Messages"));
	}

	/**
	 * @throws UnsupportedOperationException when editable is set to true.
	 */
	@Override
	public void setEditable(boolean b) {
		if(b) throw new UnsupportedOperationException(
				"This textarea object is read-only to users. ");
		else this.textarea.setEditable(false);
	}

	/**
	 * Adds a new message to the box list. Does nothing if the model is null or
	 * the string is null or empty.
	 */
	@Override
	public void append(String str) {
		textarea.append("* " + str + "\n");
	}
}

Add missing border to messages box


package org.metaborg.meta.lang.dynsem.interpreter.nabl2.sg.nodes;

import org.metaborg.meta.lang.dynsem.interpreter.nabl2.NaBL2SolutionUtils;
import org.metaborg.meta.lang.dynsem.interpreter.nabl2.sg.TermIndex;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.NativeOpBuild;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.TermBuild;
import org.metaborg.meta.lang.dynsem.interpreter.terms.ITerm;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;

@NodeChild(value = "term", type = TermBuild.class)
public abstract class GetTopLevelTermIndex extends NativeOpBuild {

	public GetTopLevelTermIndex(SourceSection source) {
		super(source);
	}

	@Specialization
	public TermIndex executeTermIndex(ITerm term) {
		mb.nabl2.stratego.TermIndex termIndex = NaBL2SolutionUtils.getTermIndex(nabl2Context(), term.getStrategoTerm());

		return new TermIndex(termIndex.getResource(), 0);
	}

	public static GetTopLevelTermIndex create(SourceSection source, TermBuild term) {
		return ScopeNodeFactories.createGetTopLevelTermIndex(source, term);
	}
}

package org.metaborg.meta.lang.dynsem.interpreter.nabl2.sg.nodes;

import org.metaborg.meta.lang.dynsem.interpreter.nabl2.NaBL2SolutionUtils;
import org.metaborg.meta.lang.dynsem.interpreter.nabl2.sg.TermIndex;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.NativeOpBuild;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.TermBuild;
import org.metaborg.meta.lang.dynsem.interpreter.terms.ITerm;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;

@NodeChild(value = "term", type = TermBuild.class)
public abstract class GetTopLevelTermIndex extends NativeOpBuild {

	public GetTopLevelTermIndex(SourceSection source) {
		super(source);
	}

	@Specialization
	public TermIndex executeTermIndex(ITerm term) {
		mb.nabl2.stratego.TermIndex termIndex = NaBL2SolutionUtils.getTermIndex(term.getStrategoTerm());

		return new TermIndex(termIndex.getResource(), 0);
	}

	public static GetTopLevelTermIndex create(SourceSection source, TermBuild term) {
		return ScopeNodeFactories.createGetTopLevelTermIndex(source, term);
	}
}

Fix incorrect method call after a previous refactoring


/*
 * Mutability Detector
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * Further licensing information for this project can be found in
 * 		license/LICENSE.txt
 */

package org.mutabilitydetector.unittesting.assertionbenchmarks;

import java.math.BigDecimal;

import org.mutabilitydetector.cli.CommandLineOptions;
import org.mutabilitydetector.cli.RunMutabilityDetector;

import com.google.classpath.ClassPath;
import com.google.classpath.ClassPathFactory;

public class CheckSomeClass {

	public static void main(String[] args) {
		//checkClass(TestIllegalFieldValueException.class);
//		checkClass(DurationField.class);
		checkClass(BigDecimal.class);
	}

	private static void checkClass(Class<?> toAnalyse) {
		ClassPath cp = new ClassPathFactory().createFromJVM();
		String match = toAnalyse.getName().replace("$", "\\$");
		CommandLineOptions options = new CommandLineOptions(System.out, "-v", "-match", match);
		new RunMutabilityDetector(cp, options).run();
	}

}

/*
 * Mutability Detector
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * Further licensing information for this project can be found in
 * 		license/LICENSE.txt
 */

package org.mutabilitydetector.unittesting.assertionbenchmarks;

import java.math.BigDecimal;

import org.mutabilitydetector.cli.CommandLineOptions;
import org.mutabilitydetector.cli.RunMutabilityDetector;
import org.mutabilitydetector.repackaged.com.google.classpath.ClassPath;
import org.mutabilitydetector.repackaged.com.google.classpath.ClassPathFactory;

public class CheckSomeClass {

	public static void main(String[] args) {
		//checkClass(TestIllegalFieldValueException.class);
//		checkClass(DurationField.class);
		checkClass(BigDecimal.class);
	}

	private static void checkClass(Class<?> toAnalyse) {
		ClassPath cp = new ClassPathFactory().createFromJVM();
		String match = toAnalyse.getName().replace("$", "\\$");
		CommandLineOptions options = new CommandLineOptions(System.out, "-v", "-match", match);
		new RunMutabilityDetector(cp, options).run();
	}

}

Use the repackaged versions of classes.


/*
 * Copyright Myrrix Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.myrrix.client.translating;

public final class GenericTranslatedRecommendedItem implements TranslatedRecommendedItem {

  private final String itemID;
  private final float value;

  public GenericTranslatedRecommendedItem(String itemID, float value) {
    this.itemID = itemID;
    this.value = value;
  }

  @Override
  public String getItemID() {
    return itemID;
  }

  @Override
  public float getValue() {
    return value;
  }

}

/*
 * Copyright Myrrix Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.myrrix.client.translating;

import java.io.Serializable;

import com.google.common.base.Preconditions;
import org.apache.mahout.common.RandomUtils;

/**
 *
A simple implementation of {@link TranslatedRecommendedItem}.

 *
 * @author Sean Owen
 */
public final class GenericTranslatedRecommendedItem implements TranslatedRecommendedItem, Serializable {

  private final String itemID;
  private final float value;

  /**
   * @throws IllegalArgumentException if item is null or value is NaN or infinite
   */
  public GenericTranslatedRecommendedItem(String itemID, float value) {
    Preconditions.checkNotNull(itemID);
    Preconditions.checkArgument(!Float.isNaN(value) && !Float.isInfinite(value));
    this.itemID = itemID;
    this.value = value;
  }

  @Override
  public String getItemID() {
    return itemID;
  }

  @Override
  public float getValue() {
    return value;
  }

  @Override
  public String toString() {
    return "GenericTranslatedRecommendedItem[item:" + itemID + ", value:" + value + ']';
  }

  @Override
  public int hashCode() {
    return itemID.hashCode() ^ RandomUtils.hashFloat(value);
  }

  @Override
  public boolean equals(Object o) {
    if (!(o instanceof GenericTranslatedRecommendedItem)) {
      return false;
    }
    GenericTranslatedRecommendedItem other = (GenericTranslatedRecommendedItem) o;
    return itemID.equals(other.getItemID()) && value == other.getValue();
  }

}

Add a few more changes to be consistent with GenericRecommendedItem, like toString()


/*
 * Copyright 2015 Ryan Gilera.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.daytron.revworks.ui.constants;

/**
 *
 * @author Ryan Gilera
 */
public enum LoginValidationNum {
    STUDENT_ID_MIN_VALUE(10000),
    STUDENT_ID_MAX_VALUE(99999),
    STUDENT_ID_LENGTH(5),
    EMAIL_MAX_LENGTH(254),
    PASSWORD_MAX_LENGTH(16),
    PASSWORD_MIN_LENGTH(6)
    ;
    private final int value;

    private LoginValidationNum(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }

}

/*
 * Copyright 2015 Ryan Gilera.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.daytron.revworks.ui.constants;

/**
 *
 * @author Ryan Gilera
 */
public enum LoginValidationNum {
    STUDENT_ID_MIN_VALUE(100000),
    STUDENT_ID_MAX_VALUE(999999),
    STUDENT_ID_LENGTH(6),
    EMAIL_MAX_LENGTH(254),
    PASSWORD_MAX_LENGTH(16),
    PASSWORD_MIN_LENGTH(6)
    ;
    private final int value;

    private LoginValidationNum(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }

}

Update range to 6 figures


package protocolsupport.protocol.packet.middleimpl;

import io.netty.buffer.ByteBuf;
import protocolsupport.protocol.packet.PacketType;

public interface RunnableTransformOperation extends Runnable, IPacketData {

	@Override
	default PacketType getPacketType() {
		return PacketType.NONE;
	}

	@Override
	default void writeData(ByteBuf to) {
		run();
	}

	@Override
	default void recycle() {
	}

}

package protocolsupport.protocol.packet.middleimpl;

import io.netty.buffer.ByteBuf;
import protocolsupport.protocol.packet.PacketType;

public class RunnableTransformOperation implements IPacketData {

	protected final Runnable runnable;
	public RunnableTransformOperation(Runnable runnable) {
		this.runnable = runnable;
	}

	@Override
	public void writeData(ByteBuf to) {
		runnable.run();
	}

	@Override
	public int getDataLength() {
		return 0;
	}

	@Override
	public PacketType getPacketType() {
		return PacketType.NONE;
	}

	@Override
	public void recycle() {
	}

}

Make runnabletransformoperation into a class instead


package kfs.springutils;

import java.io.IOException;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author pavedrim
 */
public class RunApp {

    public static void run(String profileName) {
        run(profileName, "pidfile", "appContext.xml");
    }

    public static void run(String profileName, String pidPropertyFilename, String contextFile) {
        if (pidPropertyFilename != null) {
            String pidf = System.getProperty(pidPropertyFilename);
            if ((pidf != null) && !pidf.isEmpty()) {
                ProcessBuilder pb = new ProcessBuilder("/bin/bash", "-c", "echo $PPID > " + pidf);
                try {
                    Process p = pb.start();
                } catch (IOException e) {
                }
            }
        }
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
        ctx.setConfigLocation(contextFile);
        ctx.getEnvironment().setActiveProfiles(profileName);
        ctx.refresh();
    }
}

package kfs.springutils;

import java.io.IOException;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author pavedrim
 */
public class RunApp {

    public static String defaultContextFile = "appContext.xml";
    public static String defaultPidFilePropertyName = "pidfile";

    public static void run(String profileName) {
        run(profileName, defaultPidFilePropertyName, defaultContextFile);
    }

    public static void run(String profileName, String pidPropertyFilename, String contextFile) {
        if (pidPropertyFilename != null) {
            String pidf = System.getProperty(pidPropertyFilename);
            if ((pidf != null) && !pidf.isEmpty()) {
                ProcessBuilder pb = new ProcessBuilder("/bin/bash", "-c", "echo $PPID > " + pidf);
                try {
                    Process p = pb.start();
                } catch (IOException e) {
                }
            }
        }
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
        ctx.setConfigLocation(contextFile);
        ctx.getEnvironment().setActiveProfiles(profileName);
        ctx.refresh();
    }
}

Use fafault values as a constats


package com.example.android.androidsimulator;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class AddContactsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_contacts);
    }
}

package com.example.android.androidsimulator;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class AddContactsActivity extends AppCompatActivity {

    Toast toast;
    SharedPreferences preferences;
    SharedPreferences.Editor editor;
    EditText nameContact;
    EditText numberContact;
    Button buttonAddContact;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_contacts);

        nameContact = (EditText) findViewById(R.id.nameContact_editText);
        numberContact = (EditText) findViewById(R.id.numberContact_editText);
        buttonAddContact = (Button) findViewById(R.id.addContact_button);

        buttonAddContact.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                addContact();
            }
        });
    }

    private void addContact() {
        // SharedPreferences to save data on internal storage
        preferences = PreferenceManager.getDefaultSharedPreferences(this);
        editor = preferences.edit();

        int totalContacts = preferences.getInt("totalContacts", 0);

        CharSequence validationMessage;
        String name = String.valueOf(nameContact.getText());
        String number = String.valueOf(numberContact.getText());

        // validation of contact
        if (name.isEmpty()) {
            validationMessage = "You need to insert a name";
        }
        else if (number.isEmpty()) {
            validationMessage = "You need to insert a number";
        }
        else {
            validationMessage = "Added contact";
            totalContacts += 1;

            // add info of contact on internal storage
            editor.putInt("totalContacts", totalContacts);
            editor.putString("nameContact" + totalContacts, name);
            editor.putInt("numberContact" + totalContacts, Integer.valueOf(number));
            editor.apply();
        }

       toast = Toast.makeText(this, validationMessage, Toast.LENGTH_SHORT);
       toast.show();
    }
}

Add contacts to internal storage


/*
 *    Copyright (C) 2015 Haruki Hasegawa
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.h6ah4i.android.example.advrecyclerview.common.utils;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewParent;

public class AdapterUtils {
    public static View findParentViewHolderItemView(View v) {
        final ViewParent parent = v.getParent();
        if (parent instanceof RecyclerView) {
            // returns the passed instance if the parent is RecyclerView
            return v;
        } else if (v instanceof View) {
            // check the parent view recursively
            return findParentViewHolderItemView((View) parent);
        } else {
            return null;
        }
    }
}

/*
 *    Copyright (C) 2015 Haruki Hasegawa
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.h6ah4i.android.example.advrecyclerview.common.utils;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewParent;

public class AdapterUtils {
    public static View findParentViewHolderItemView(View v) {
        final ViewParent parent = v.getParent();
        if (parent instanceof RecyclerView) {
            // returns the passed instance if the parent is RecyclerView
            return v;
        } else if (parent instanceof View) {
            // check the parent view recursively
            return findParentViewHolderItemView((View) parent);
        } else {
            return null;
        }
    }
}

Fix a lint warned bug


package io.subutai.hub.share.dto;

/**
 * Created by ${Zubaidullo} on 2/18/16.
 */
public enum SystemConfigurationType
{
    SUBUTAI_SOCIAL, SUBUTAI_SOCIAL_PLUGIN, SUBUTAI_SOCIAL_HUB
}

package io.subutai.hub.share.dto;

/**
 * Created by ${Zubaidullo} on 2/18/16.
 */
public enum SystemConfigurationType
{
    SUBUTAI_SOCIAL, SUBUTAI_SOCIAL_PLUGIN, SUBUTAI_SOCIAL_HUB, RESOURCE_HOST, P2P
}

Add system config type: RH and P2P


/*
 * Copyright 2021, TeamDev. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package io.spine.server.entity.given.repository;

import io.spine.server.entity.TransactionalEntity;
import io.spine.test.entity.Project;
import io.spine.test.entity.ProjectId;

public class ProjectEntity extends TransactionalEntity<ProjectId, Project, Project.Builder> {
    private ProjectEntity(ProjectId id) {
        super(id);
    }
}

/*
 * Copyright 2021, TeamDev. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package io.spine.server.entity.given.repository;

import io.spine.server.entity.TransactionalEntity;
import io.spine.test.entity.Project;
import io.spine.test.entity.ProjectId;

public final class ProjectEntity extends TransactionalEntity<ProjectId, Project, Project.Builder> {

    private ProjectEntity(ProjectId id) {
        super(id);
    }
}

Reformat the code. Mark the type `final`.


package com.github.florent37.materialviewpager.header;

import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;

/**
 * Created by florentchampigny on 10/06/15.
 */
public class HeaderDesign {
    protected int color;
    protected int colorRes;
    protected String imageUrl;
    protected Drawable drawable;

    private HeaderDesign() {
    }

    public static HeaderDesign fromColorAndUrl(@ColorInt int color, String imageUrl) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.color = color;
        headerDesign.imageUrl = imageUrl;
        return headerDesign;
    }

    public static HeaderDesign fromColorResAndUrl(@ColorRes int colorRes, String imageUrl) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.colorRes = colorRes;
        headerDesign.imageUrl = imageUrl;
        return headerDesign;
    }

    public static HeaderDesign fromColorAndDrawable(@ColorInt int color, Drawable drawable) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.drawable = drawable;
        headerDesign.color = color;
        return headerDesign;
    }

    public static HeaderDesign fromColorResAndDrawable(@ColorRes int colorRes, String imageUrl) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.colorRes = colorRes;
        headerDesign.imageUrl = imageUrl;
        return headerDesign;
    }

    public int getColor() {
        return color;
    }

    public int getColorRes() {
        return colorRes;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public Drawable getDrawable() {
        return drawable;
    }
}

package com.github.florent37.materialviewpager.header;

import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;

/**
 * Created by florentchampigny on 10/06/15.
 */
public class HeaderDesign {
    protected int color;
    protected int colorRes;
    protected String imageUrl;
    protected Drawable drawable;

    private HeaderDesign() {
    }

    public static HeaderDesign fromColorAndUrl(@ColorInt int color, String imageUrl) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.color = color;
        headerDesign.imageUrl = imageUrl;
        return headerDesign;
    }

    public static HeaderDesign fromColorResAndUrl(@ColorRes int colorRes, String imageUrl) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.colorRes = colorRes;
        headerDesign.imageUrl = imageUrl;
        return headerDesign;
    }

    public static HeaderDesign fromColorAndDrawable(@ColorInt int color, Drawable drawable) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.drawable = drawable;
        headerDesign.color = color;
        return headerDesign;
    }

    public static HeaderDesign fromColorResAndDrawable(@ColorRes int colorRes, Drawable drawable) {
        HeaderDesign headerDesign = new HeaderDesign();
        headerDesign.colorRes = colorRes;
        headerDesign.drawable = drawable;
        return headerDesign;
    }

    public int getColor() {
        return color;
    }

    public int getColorRes() {
        return colorRes;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public Drawable getDrawable() {
        return drawable;
    }
}

Fix what seems to be a mistake in fromColorResAndDrawable


package org.springframework.support;

import org.springframework.versions.AncestorRootId;
import org.springframework.versions.SuccessorId;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class TestEntityVersioned {
    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id;

    // these are required to satisfy the
    @AncestorRootId private String ancestralRootId;
    @SuccessorId private String successorId;
}

package org.springframework.support;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.springframework.versions.AncestorId;
import org.springframework.versions.AncestorRootId;
import org.springframework.versions.SuccessorId;

@Entity
public class TestEntityVersioned {
    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id;

    // these are required to satisfy the
    @AncestorRootId private String ancestralRootId;
    @AncestorId private String ancestorId;
    @SuccessorId private String successorId;
}

Make test entities for versioned repositories implement an ancestorId field


package heufybot.core;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import heufybot.utils.FileUtils;

public class Logger
{
	public static void log(String line)
	{
		//Timestamp line
		DateFormat dateFormat = new SimpleDateFormat("[HH:mm]");
		Date date = new Date();
		line = dateFormat.format(date) + " " + line;

		//Output to console
		System.out.println(line);

		//Output to logfile
		FileUtils.writeFileAppend("test.log", line + "\n");
	}

	public static void error(String errorSource, String line)
	{
		System.err.println(errorSource + " - ERROR: " + line);
	}
}

package heufybot.core;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import heufybot.utils.FileUtils;

public class Logger
{
	public static void log(String line, String target)
	{
		//Timestamp line
		DateFormat dateFormat = new SimpleDateFormat("[HH:mm]");
		Date date = new Date();
		line = dateFormat.format(date) + " " + line;

		//Output to console
		if(target.equals(""))
		{
			System.out.println(line);
		}
		else
		{
			System.out.println(target + " - " + line);
		}

		//Output to logfile
		FileUtils.writeFileAppend("test.log", line + "\n");
	}

	public static void log(String line)
	{
		log(line, "");
	}

	public static void error(String errorSource, String line)
	{
		System.err.println(errorSource + " - ERROR: " + line);
	}
}

Add logging to a target, for creating logfiles for seperate channels later


package uk.ac.ebi.spot.goci.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

/**
 * Created by emma on 27/11/14.
 *
 * @author emma
 *         <p>
 *         Model object representing status assigned to studies
 */

@Entity
public class CurationStatus {
    @Id
    @GeneratedValue
    private Long id;

    private String status;

    private String seqnbr;

    // JPA no-args constructor
    public CurationStatus() {
    }

    public CurationStatus(Long id, String curationStatus, String seqnbr) {
        this.id = id;
        this.status = curationStatus;
        this.seqnbr = seqnbr;
    }

    public Long getId() {
        return id;
    }

    public String getStatus() {
        return status;
    }

    public String getSeqnbr() {
        return seqnbr;
    }

    @Override
    public String toString() {
        return "CurationStatus{" +
                "id=" + id +
                ", curationStatus='" + status + '\'' +
                ", seqnbr='" + seqnbr + '\'' +
                '}';
    }
}

package uk.ac.ebi.spot.goci.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

/**
 * Created by emma on 27/11/14.
 *
 * @author emma
 *         <p>
 *         Model object representing status assigned to studies
 */

@Entity
public class CurationStatus {
    @Id
    @GeneratedValue
    private Long id;

    private String status;

    private String seqnbr;

    // JPA no-args constructor
    public CurationStatus() {
    }

    public CurationStatus(Long id, String curationStatus, String seqnbr) {
        this.id = id;
        this.status = curationStatus;
        this.seqnbr = seqnbr;
    }

    public Long getId() {
        return id;
    }

    public String getStatus() {
        return status;
    }

    public String getSeqnbr() {
        return seqnbr;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public void setSeqnbr(String seqnbr) {
        this.seqnbr = seqnbr;
    }
}

Remove toString method, add setters


package com.palantir.atlasdb.keyvalue.partition;

import com.palantir.atlasdb.keyvalue.api.RangeRequest;
import com.palantir.common.annotation.Immutable;

@Immutable public class ConsistentRingRangeRequest {
    private final RangeRequest rangeRequest;
    public RangeRequest get() {
        return rangeRequest;
    }
    private ConsistentRingRangeRequest(RangeRequest rangeRequest) {
        this.rangeRequest = rangeRequest;
    }
    public static ConsistentRingRangeRequest of(RangeRequest rangeRequest) {
        return new ConsistentRingRangeRequest(rangeRequest);
    }
    public String toString() {
        return "CRRR=[" + rangeRequest + "]";
    }
}

package com.palantir.atlasdb.keyvalue.partition;

import com.palantir.atlasdb.keyvalue.api.RangeRequest;
import com.palantir.common.annotation.Immutable;

@Immutable public class ConsistentRingRangeRequest {
    private final RangeRequest rangeRequest;
    public RangeRequest get() {
        return rangeRequest;
    }
    private ConsistentRingRangeRequest(RangeRequest rangeRequest) {
        this.rangeRequest = rangeRequest;
    }
    public static ConsistentRingRangeRequest of(RangeRequest rangeRequest) {
        return new ConsistentRingRangeRequest(rangeRequest);
    }
    public String toString() {
        return "CRRR=[" + rangeRequest + "]";
    }
    @Override
    public boolean equals(Object other) {
        if (other instanceof ConsistentRingRangeRequest == false) {
            return false;
        }
        ConsistentRingRangeRequest otherCrrr = (ConsistentRingRangeRequest) other;
        return get().equals(otherCrrr.get());
    }
}

Add equals impl to CRRR


package protocolsupport.protocol.transformer.middlepacketimpl.serverbound.play.v_1_4_1_5_1_6_1_7;

import java.io.IOException;

import net.minecraft.server.v1_9_R1.BlockPosition;
import protocolsupport.protocol.PacketDataSerializer;
import protocolsupport.protocol.transformer.middlepacket.serverbound.play.MiddleBlockPlace;

public class BlockPlace extends MiddleBlockPlace {

	@Override
	public void readFromClientData(PacketDataSerializer serializer) throws IOException {
		position = new BlockPosition(serializer.readInt(), serializer.readUnsignedByte(), serializer.readInt());
		face = serializer.readUnsignedByte();
		cX = serializer.readUnsignedByte();
		cY = serializer.readUnsignedByte();
		cZ = serializer.readUnsignedByte();
	}

}

package protocolsupport.protocol.transformer.middlepacketimpl.serverbound.play.v_1_4_1_5_1_6_1_7;

import java.io.IOException;

import net.minecraft.server.v1_9_R1.BlockPosition;
import protocolsupport.protocol.PacketDataSerializer;
import protocolsupport.protocol.transformer.middlepacket.serverbound.play.MiddleBlockPlace;

public class BlockPlace extends MiddleBlockPlace {

	@Override
	public void readFromClientData(PacketDataSerializer serializer) throws IOException {
		position = new BlockPosition(serializer.readInt(), serializer.readUnsignedByte(), serializer.readInt());
		face = serializer.readUnsignedByte();
		serializer.readItemStack();
		cX = serializer.readUnsignedByte();
		cY = serializer.readUnsignedByte();
		cZ = serializer.readUnsignedByte();
	}

}

Fix block place packet reading


package com.servinglynk.hmis.warehouse.service.converter;

import com.servinglynk.hmis.warehouse.core.model.EnrollmentCoc;
public class EnrollmentCocConverter  extends BaseConverter {

   public static com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc modelToEntity (EnrollmentCoc model ,com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc entity) {
       if(entity==null) entity = new com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc();
       	  entity.setId(model.getEnrollmentCocId());
          entity.setCocCode(model.getCocCode());
       return entity;
   }

   public static EnrollmentCoc entityToModel (com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc entity) {
       EnrollmentCoc model = new EnrollmentCoc();
       model.setEnrollmentCocId(entity.getId());
       model.setCocCode(entity.getCocCode());
       model.setEnrollmentId(entity.getEnrollmentid().getId());
       model.setProjectCocId(entity.getProjectCoc().getId());
       model.setDateCreated(entity.getDateCreated());
       model.setDateUpdated(entity.getDateUpdated());
       return model;
   }

}

package com.servinglynk.hmis.warehouse.service.converter;

import com.servinglynk.hmis.warehouse.core.model.EnrollmentCoc;
public class EnrollmentCocConverter  extends BaseConverter {

   public static com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc modelToEntity (EnrollmentCoc model ,com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc entity) {
       if(entity==null) entity = new com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc();
       	  entity.setId(model.getEnrollmentCocId());
          entity.setCocCode(model.getCocCode());
       return entity;
   }

   public static EnrollmentCoc entityToModel (com.servinglynk.hmis.warehouse.model.v2014.EnrollmentCoc entity) {
       EnrollmentCoc model = new EnrollmentCoc();
       model.setEnrollmentCocId(entity.getId());
       model.setCocCode(entity.getCocCode());
       model.setEnrollmentId(entity.getEnrollmentid() !=null ? entity.getEnrollmentid().getId() : null);
       model.setProjectCocId(entity.getProjectCoc() !=null ? entity.getProjectCoc().getId() : null);
       model.setDateCreated(entity.getDateCreated());
       model.setDateUpdated(entity.getDateUpdated());
       return model;
   }

}

Fix NPE in the enrollmentcoc api


package org.javarosa.xml.util;

import org.javarosa.core.services.locale.Localization;

/**
 * Invalid structure error that can _potentially_ be recovered from via
 * advanced user intervention. Useful for notifying the user that the issue lies
 * on the server.
 *
 * @author Phillip Mates (pmates@dimagi.com).
 */
public class ActionableInvalidStructureException extends InvalidStructureException {
    private String localizationKey;
    private String[] localizationParameters;

    public ActionableInvalidStructureException(String localizationKey,
                                                String[] localizationParameters,
                                                String message) {
        super(message);
        this.localizationKey = localizationKey;
        this.localizationParameters = localizationParameters;
    }

    @Override
    public String getLocalizedMessage() {
        if (localizationKey != null) {
            return Localization.get(localizationKey, localizationParameters);
        } else {
            return getMessage();
        }
    }
}

package org.javarosa.xml.util;

import org.javarosa.core.services.locale.Localization;
import org.javarosa.core.util.NoLocalizedTextException;

/**
 * Invalid structure error that can _potentially_ be recovered from via
 * advanced user intervention. Useful for notifying the user that the issue lies
 * on the server.
 *
 * @author Phillip Mates (pmates@dimagi.com).
 */
public class ActionableInvalidStructureException extends InvalidStructureException {
    private String localizationKey;
    private String[] localizationParameters;

    public ActionableInvalidStructureException(String localizationKey,
                                                String[] localizationParameters,
                                                String message) {
        super(message);
        this.localizationKey = localizationKey;
        this.localizationParameters = localizationParameters;
    }

    @Override
    public String getLocalizedMessage() {
        if (localizationKey != null) {
            try {
                return Localization.get(localizationKey, localizationParameters);
            } catch (NoLocalizedTextException e) {
                return getMessage();
            }
        } else {
            return getMessage();
        }
    }
}

Add error handling for localization failures


/*
 * Copyright 2015-2017 Hewlett Packard Enterprise Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.frontend.find.idol.parametricfields;

import com.hp.autonomy.frontend.find.core.parametricfields.AbstractParametricValuesServiceIT;

public class IdolParametricValuesServiceIT extends AbstractParametricValuesServiceIT {}

/*
 * Copyright 2015-2017 Hewlett Packard Enterprise Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.frontend.find.idol.parametricfields;

import com.hp.autonomy.frontend.find.core.parametricfields.AbstractParametricValuesServiceIT;
import org.springframework.test.annotation.DirtiesContext;

@DirtiesContext
public class IdolParametricValuesServiceIT extends AbstractParametricValuesServiceIT {}

Add @DirtiesContext for test preceding the failing test


/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2012 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.undertow.servlet.core;

import io.undertow.server.HttpServerExchange;
import io.undertow.servlet.api.ThreadSetupAction;

/**
 * @author Stuart Douglas
 */
public class ContextClassLoaderSetupAction implements ThreadSetupAction {

    private final ClassLoader classLoader;

    public ContextClassLoaderSetupAction(final ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    @Override
    public Handle setup(final HttpServerExchange exchange) {
        final ClassLoader old = SecurityActions.getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        return new Handle() {
            @Override
            public void tearDown() {
                SecurityActions.setContextClassLoader(old);
            }
        };
    }
}

/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2012 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.undertow.servlet.core;

import io.undertow.server.HttpServerExchange;
import io.undertow.servlet.api.ThreadSetupAction;

/**
 * @author Stuart Douglas
 */
public class ContextClassLoaderSetupAction implements ThreadSetupAction {

    private final ClassLoader classLoader;

    public ContextClassLoaderSetupAction(final ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    @Override
    public Handle setup(final HttpServerExchange exchange) {
        final ClassLoader old = SecurityActions.getContextClassLoader();
        SecurityActions.setContextClassLoader(classLoader);
        return new Handle() {
            @Override
            public void tearDown() {
                SecurityActions.setContextClassLoader(old);
            }
        };
    }
}

Use SecurityActions to set the TCCL


package io.quarkus.hibernate.orm.runtime.customized;

import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;

import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;

public final class QuarkusJtaPlatform extends AbstractJtaPlatform {

    public static final QuarkusJtaPlatform INSTANCE = new QuarkusJtaPlatform();

    private QuarkusJtaPlatform() {
        //nothing
    }

    @Override
    protected TransactionManager locateTransactionManager() {
        return com.arjuna.ats.jta.TransactionManager.transactionManager();
    }

    @Override
    protected UserTransaction locateUserTransaction() {
        return com.arjuna.ats.jta.UserTransaction.userTransaction();
    }

}

package io.quarkus.hibernate.orm.runtime.customized;

import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;

import org.hibernate.engine.transaction.jta.platform.internal.JtaSynchronizationStrategy;
import org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerAccess;
import org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerBasedSynchronizationStrategy;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;

public final class QuarkusJtaPlatform implements JtaPlatform, TransactionManagerAccess {

    public static final QuarkusJtaPlatform INSTANCE = new QuarkusJtaPlatform();

    private final JtaSynchronizationStrategy tmSynchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy(
            this);
    private volatile TransactionManager transactionManager;
    private volatile UserTransaction userTransaction;

    private QuarkusJtaPlatform() {
        //nothing
    }

    @Override
    public TransactionManager retrieveTransactionManager() {
        TransactionManager transactionManager = this.transactionManager;
        if (transactionManager == null) {
            transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
            this.transactionManager = transactionManager;
        }
        return transactionManager;
    }

    @Override
    public TransactionManager getTransactionManager() {
        return retrieveTransactionManager();
    }

    @Override
    public UserTransaction retrieveUserTransaction() {
        UserTransaction userTransaction = this.userTransaction;
        if (this.userTransaction == null) {
            userTransaction = com.arjuna.ats.jta.UserTransaction.userTransaction();
            this.userTransaction = userTransaction;
        }
        return userTransaction;
    }

    @Override
    public Object getTransactionIdentifier(final Transaction transaction) {
        return transaction;
    }

    @Override
    public void registerSynchronization(Synchronization synchronization) {
        this.tmSynchronizationStrategy.registerSynchronization(synchronization);
    }

    @Override
    public boolean canRegisterSynchronization() {
        return this.tmSynchronizationStrategy.canRegisterSynchronization();
    }

    @Override
    public int getCurrentStatus() throws SystemException {
        return this.retrieveTransactionManager().getStatus();
    }

}

Reimplement the QuarkusJTAPlatform to avoid leaking the ORM registry


// JSPyIterableObject.java

/**
*    Copyright (C) 2008 10gen Inc.
*
*    This program is free software: you can redistribute it and/or  modify
*    it under the terms of the GNU Affero General Public License, version 3,
*    as published by the Free Software Foundation.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU Affero General Public License for more details.
*
*    You should have received a copy of the GNU Affero General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package ed.lang.python;

import java.util.*;

import org.python.core.*;

public class JSPyIterableObject extends JSPyObjectWrapper implements Iterable {
    public JSPyIterableObject( PyObject p ){
        super(p);
    }

    public Iterator iterator(){
        return _p.asIterable().iterator();
    }
}

// JSPyIterableObject.java

/**
*    Copyright (C) 2008 10gen Inc.
*
*    This program is free software: you can redistribute it and/or  modify
*    it under the terms of the GNU Affero General Public License, version 3,
*    as published by the Free Software Foundation.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU Affero General Public License for more details.
*
*    You should have received a copy of the GNU Affero General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package ed.lang.python;

import java.util.*;

import org.python.core.*;

public class JSPyIterableObject extends JSPyObjectWrapper implements Iterable {
    public JSPyIterableObject( PyObject p ){
        super(p);
    }

    public Iterator iterator(){
        return new IterWrapper( _p.asIterable().iterator() );
    }

    class IterWrapper implements Iterator {
        Iterator _iter;
        IterWrapper( Iterator i ){
            _iter = i;
        }
        public Object next(){
            return Python.toJS( next() );
        }
    }
}

Convert iterated Python objects to JS.


/*******************************************************************************
 * Copyright (c) 2007 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.ui.extensions;

import org.eclipse.birt.report.model.api.DesignElementHandle;

/**
 * ReportItemViewAdapter
 */
public abstract class ReportItemViewAdapter implements IReportItemViewProvider
{

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.birt.report.designer.ui.extensions.IReportItemViewProvider#createView(org.eclipse.birt.report.model.api.DesignElementHandle)
	 */
	public DesignElementHandle createView( DesignElementHandle host )
	{
		return null;
	}

}

/*******************************************************************************
 * Copyright (c) 2007 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.ui.extensions;

import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.report.model.api.DesignElementHandle;

/**
 * ReportItemViewAdapter
 */
public abstract class ReportItemViewAdapter implements IReportItemViewProvider
{

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.birt.report.designer.ui.extensions.IReportItemViewProvider#createView(org.eclipse.birt.report.model.api.DesignElementHandle)
	 */
	public DesignElementHandle createView( DesignElementHandle host ) throws BirtException
	{
		return null;
	}

}

Add BirtException declaration on createView method.


/*******************************************************************************
 * Copyright (c) 1998, 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
 * which accompanies this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 ******************************************************************************/
package org.eclipse.persistence.internal.oxm.record.deferred;

import org.eclipse.persistence.oxm.record.UnmarshalRecord;
import org.xml.sax.SAXException;

/**
 *
Purpose: Class to represent the characters event
 *
Responsibilities:

 *
 Execute the characters event on the given unmarshalRecord with the specified arguments
 *

 */
public class CharactersEvent extends SAXEvent {
    private char[] characters;
    private int start;
    private int end;

    public CharactersEvent(char[] theCharacters, int theStart, int theEnd) {
        super();
        characters = theCharacters;
        start = theStart;
        end = theEnd;
    }

    public void processEvent(UnmarshalRecord unmarshalRecord) throws SAXException {
        unmarshalRecord.characters(characters, start, end);
    }
}

/*******************************************************************************
 * Copyright (c) 1998, 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
 * which accompanies this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 ******************************************************************************/
package org.eclipse.persistence.internal.oxm.record.deferred;

import org.eclipse.persistence.oxm.record.UnmarshalRecord;
import org.xml.sax.SAXException;

/**
 *
Purpose: Class to represent the characters event
 *
Responsibilities:

 *
 Execute the characters event on the given unmarshalRecord with the specified arguments
 *

 */
public class CharactersEvent extends SAXEvent {
    private char[] characters;
    private int start;
    private int end;

    public CharactersEvent(char[] theCharacters, int theStart, int theEnd) {
        super();
        //clone the character array. The one passed in from the original SAX event may change.
        characters = theCharacters.clone();
        start = theStart;
        end = theEnd;
    }

    public void processEvent(UnmarshalRecord unmarshalRecord) throws SAXException {
        unmarshalRecord.characters(characters, start, end);
    }
}

Fix for nightly build test failures Reviewed by David McCann


package com.edulify.modules.geolocation;

import org.junit.Test;
import play.test.WithApplication;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.*;
import static play.test.Helpers.*;

/**
 * Created by sovaalexandr
 */
public class GeolocationServiceTest extends WithApplication {

  @Test
  public void testGetGeolocation() throws Exception {
    Map<String, Object> config = new HashMap<>(1);
    config.put("geolocation.provider", "com.edulify.modules.geolocation.providers.FreegeoipProvider");
    List<String> plugins = new ArrayList<>(1);
    plugins.add(GeolocationPlugin.class.getCanonicalName());
    running(fakeApplication(config, plugins), new Runnable() {
      @Override
      public void run() {
        String ipAddress = "192.30.252.129";
        Geolocation geolocation = GeolocationService.getGeolocation(ipAddress);
        assertEquals(ipAddress, geolocation.getIp());
      }
    });
  }
}

Remove duplication of code at deprecated Sync service Add new line to the end of file


/*
Copyright 2020 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.google.gpay.virtualqueue.backendservice.repository;

import java.util.Map;
import java.util.UUID;

import com.google.gpay.virtualqueue.backendservice.model.Shop;
import com.google.gpay.virtualqueue.backendservice.proto.CreateShopRequest;

public interface VirtualQueueRepository {

    public UUID createShop(CreateShopRequest createShopRequest);

    public Map<UUID, Shop> getAllShops();
}

/*
Copyright 2020 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.google.gpay.virtualqueue.backendservice.repository;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.google.gpay.virtualqueue.backendservice.model.Shop;
import com.google.gpay.virtualqueue.backendservice.model.Token;
import com.google.gpay.virtualqueue.backendservice.proto.CreateShopRequest;

public interface VirtualQueueRepository {

    public UUID createShop(CreateShopRequest createShopRequest);

    public Map<UUID, Shop> getAllShops();

    public List<Token> getTokensByShopId(UUID shopId);
}

Add function to Virtual Queue Repository interface


package org.spoofax.jsglr2.integrationtest.languages;

import java.io.IOException;
import java.util.stream.Stream;

import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import org.spoofax.interpreter.terms.IStrategoTerm;
import org.spoofax.jsglr2.integrationtest.BaseTestWithParseTableFromTermWithJSGLR1;
import org.spoofax.terms.ParseError;

public class StrategoTest extends BaseTestWithParseTableFromTermWithJSGLR1 {

    public StrategoTest() throws Exception {
        setupParseTable("Stratego");
    }

    @TestFactory public Stream<DynamicTest> testAmbByExpectedAST() throws ParseError, IOException {
        String sampleProgram = getFileAsString("Stratego/ambiguity-issue.str");
        IStrategoTerm expectedAST = getFileAsAST("Stratego/ambiguity-issue.aterm");

        return testSuccessByAstString(sampleProgram, expectedAST.toString());
    }

    @TestFactory public Stream<DynamicTest> testIndentPadding() throws ParseError, IOException {
        String sampleProgram = getFileAsString("Stratego/test112.str");
        IStrategoTerm expectedAST = getFileAsAST("Stratego/test112.aterm");

        return testSuccessByAstString(sampleProgram, expectedAST.toString());
    }

}

package org.spoofax.jsglr2.integrationtest.languages;

import java.io.IOException;
import java.util.stream.Stream;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import org.spoofax.interpreter.terms.IStrategoTerm;
import org.spoofax.jsglr2.integrationtest.BaseTestWithParseTableFromTermWithJSGLR1;
import org.spoofax.terms.ParseError;

public class StrategoTest extends BaseTestWithParseTableFromTermWithJSGLR1 {

    public StrategoTest() throws Exception {
        setupParseTable("Stratego");
    }

    @TestFactory public Stream<DynamicTest> testAmbByExpectedAST() throws ParseError, IOException {
        String sampleProgram = getFileAsString("Stratego/ambiguity-issue.str");
        IStrategoTerm expectedAST = getFileAsAST("Stratego/ambiguity-issue.aterm");

        return testSuccessByAstString(sampleProgram, expectedAST.toString());
    }

    @Disabled("The {indentpadding} attribute is not supported by JSGLR2 imploding due to concerns around incremental parsing")
    @TestFactory public Stream<DynamicTest> testIndentPadding() throws ParseError, IOException {
        String sampleProgram = getFileAsString("Stratego/test112.str");
        IStrategoTerm expectedAST = getFileAsAST("Stratego/test112.aterm");

        return testSuccessByAstString(sampleProgram, expectedAST.toString());
    }

}

Disable indentpadding test, note why


package io.tetrapod.core.web;

import io.tetrapod.protocol.core.WebRoute;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class WebRoutes {

   private final Map<String,WebRoute> routes = new ConcurrentHashMap<>();

   public void setRoute(String path, int contractId, int structId) {
      // "/api/LoginRequest  contractId=2, structId=1244334
      WebRoute r = new WebRoute(path, structId, contractId);
      routes.put(path, r);
   }

   public WebRoute findRoute(String uri) {
      int ix = uri.indexOf('?');
      String path = ix < 0 ? uri : uri.substring(0, ix);
      WebRoute r = routes.get(path);
      if (r == null) {
         // allow /route/params instead of /route?params
         ix = uri.lastIndexOf('/');
         path = ix < 0 ? uri : uri.substring(0, ix);
         r = routes.get(path);
      }
      return r;
   }

}

package io.tetrapod.core.web;

import io.tetrapod.protocol.core.WebRoute;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class WebRoutes {

   private final Map<String, WebRoute> routes = new ConcurrentHashMap<>();

   public void setRoute(String path, int contractId, int structId) {
      // "/api/LoginRequest  contractId=2, structId=1244334
      WebRoute r = new WebRoute(path, structId, contractId);
      routes.put(path, r);
   }

   public WebRoute findRoute(String uri) {
      int ix = uri.indexOf('?');
      String path = ix < 0 ? uri : uri.substring(0, ix);

      WebRoute r = routes.get(path);
      if (r == null) {
         // special handling for @root paths
         for (WebRoute route : routes.values()) {
            if (path.startsWith(route.path)) {
               return route;
            }
         }
      }

      if (r == null) {
         // allow /route/params instead of /route?params
         ix = uri.lastIndexOf('/');
         path = ix < 0 ? uri : uri.substring(0, ix);
         r = routes.get(path);
      }
      return r;
   }

}

Add handling to @root WebRoute matching so we can send the whole subpath


package com.urlcrawler;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LineParserImpl implements LineParser {

    private Pattern regPattern;
    private List<URL> links = new ArrayList<URL>();

    public List<URL> extractUrl(String line) {
        Matcher m = regPattern.matcher(line);
        while (m.find()) {
            try {
                System.out.println("Converting string to URL: " + m.group(1));
                URL url = new URL(m.group(1));
                links.add(url);
            } catch (MalformedURLException e) {
            }
        }
        return links;
    }

    public void setRegularExpression(String regex) {
        this.regPattern = Pattern.compile(regex);
    }

}

package com.urlcrawler;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LineParserImpl implements LineParser {

    private Pattern regPattern;
    private List<URL> links = new ArrayList<URL>();

    public List<URL> extractUrl(String line) {
        links.clear();
        Matcher m = regPattern.matcher(line);
        while (m.find()) {
            try {
                System.out.println("Converting string to URL: " + m.group(1));
                URL url = new URL(m.group(1));
                links.add(url);
            } catch (MalformedURLException e) {
            }
        }
        return links;
    }

    public void setRegularExpression(String regex) {
        this.regPattern = Pattern.compile(regex);
    }

}

Clean links list for each new cycle.


package fault;

import fault.concurrent.DefaultResilientPromise;
import fault.concurrent.ResilientFuture;
import fault.concurrent.ResilientPromise;
import fault.utils.ResilientPatternAction;

/**
 * Created by timbrooks on 6/4/15.
 */
public class LoadBalancer<T, C> implements Pattern {

    @Override
    public ResilientFuture<T> submitAction(ResilientPatternAction action, long millisTimeout) {
        return submitAction(action, new DefaultResilientPromise(), null, millisTimeout);
    }

    @Override
    public ResilientFuture<T> submitAction(ResilientPatternAction action, ResilientCallback callback,
                                           long millisTimeout) {
        return null;
    }

    @Override
    public ResilientFuture<T> submitAction(ResilientPatternAction action, ResilientPromise promise,
                                           long millisTimeout) {
        return null;
    }

    @Override
    public ResilientFuture<T> submitAction(ResilientPatternAction action, ResilientPromise promise,
                                           ResilientCallback callback, long millisTimeout) {
        return null;
    }

    @Override
    public ResilientPromise<T> performAction(ResilientPatternAction action) {
        return null;
    }
}

package fault;

import fault.concurrent.DefaultResilientPromise;
import fault.concurrent.ResilientFuture;
import fault.concurrent.ResilientPromise;
import fault.utils.ResilientPatternAction;

/**
 * Created by timbrooks on 6/4/15.
 */
public class LoadBalancer<C> implements Pattern<C> {

    @Override
    public <T> ResilientFuture<T> submitAction(ResilientPatternAction<T, C> action, long millisTimeout) {
        return submitAction(action, new DefaultResilientPromise<T>(), null, millisTimeout);
    }

    @Override
    public <T> ResilientFuture<T> submitAction(ResilientPatternAction<T, C> action, ResilientCallback<T> callback,
                                               long millisTimeout) {
        return submitAction(action, new DefaultResilientPromise<T>(), callback, millisTimeout);
    }

    @Override
    public <T> ResilientFuture<T> submitAction(ResilientPatternAction<T, C> action, ResilientPromise<T> promise,
                                               long millisTimeout) {
        return submitAction(action, promise, null, millisTimeout);
    }

    @Override
    public <T> ResilientFuture<T> submitAction(ResilientPatternAction<T, C> action, ResilientPromise<T> promise,
                                               ResilientCallback<T> callback, long millisTimeout) {
        return submitAction(action, promise, callback, millisTimeout);
    }

    @Override
    public <T> ResilientPromise<T> performAction(ResilientPatternAction<T, C> action) {
        return null;
    }
}

Fix type relationship. And have methods calls each other


package sketch.avengergear.com;

import android.app.Activity;
import android.os.Bundle;

public class sketchUI extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

package sketch.avengergear.com;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.app.Activity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;

import org.spongycastle.jce.provider.BouncyCastleProvider;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Security;
import java.security.SecureRandom;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.Arrays;
import java.util.Map;

public class sketchUI extends Activity
{
    private static final String TAG = "SKETCH-UI";

    static {
        Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        try {
            // Create the public and private keys
            KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "BC");

            SecureRandom random = new SecureRandom();
            generator.initialize(2048, random);
            KeyPair keyPair = generator.genKeyPair();

            byte[] pri = keyPair.getPrivate().getEncoded();
            byte[] pub = keyPair.getPublic().getEncoded();

            Log.v(TAG, keyPair.getPrivate().toString() );

        } catch (NoSuchProviderException e) {
            Log.e(TAG, "No provider exception", e);
        } catch (NoSuchAlgorithmException e) {
            Log.e(TAG, "No Algorithum exception", e);
        }

    }
}

Initialize BC Private and Public Key gen test


/*
 * Copyright 2011 CodeFlux, Inc <info@teamcodeflux.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.teamcodeflux.android.adapter;

import android.content.Context;
import android.widget.SimpleAdapter;

import java.util.List;
import java.util.Map;

public abstract class AbstractSimpleAdapterBuilder<T> implements SimpleAdapterBuilder {
    private Context context;
    private List<T> data;

    public AbstractSimpleAdapterBuilder(final Context context, final List<T> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public SimpleAdapter build() {
        return new SimpleAdapter(context, data(data), resource(), from(), to());
    }

    protected abstract List<? extends Map<String, ?>> data(List<T> data);
    protected abstract int resource();
    protected abstract String[] from();
    protected abstract int[] to();
}

/*
 * Copyright 2011 CodeFlux, Inc <info@teamcodeflux.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.teamcodeflux.android.adapter;

import android.content.Context;
import android.widget.SimpleAdapter;

import java.util.List;
import java.util.Map;

public abstract class AbstractSimpleAdapterBuilder<T> implements SimpleAdapterBuilder {
    protected Context context;
    protected List<T> data;

    public AbstractSimpleAdapterBuilder(final Context context, final List<T> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public SimpleAdapter build() {
        return new SimpleAdapter(context, data(data), resource(), from(), to());
    }

    protected abstract List<? extends Map<String, ?>> data(List<T> data);
    protected abstract int resource();
    protected abstract String[] from();
    protected abstract int[] to();
}

Change access modifier for builder attributes.


package com.gentics.mesh.test.docker;

import static com.gentics.mesh.test.ClientHelper.call;
import static org.junit.Assert.assertEquals;

import org.junit.ClassRule;
import org.junit.Test;

import com.gentics.mesh.core.rest.user.UserListResponse;

import io.vertx.core.Vertx;

public class MeshDockerServerTest {

	@ClassRule
	public static MeshDockerServer server = new MeshDockerServer("gentics/mesh:0.10.0", "dummy", true, Vertx.vertx(), null, null);

	@Test
	public void testDockerImage() {
		UserListResponse response = call(() -> server.getMeshClient().findUsers());
		assertEquals(2, response.getData().size());
	}

}

package com.gentics.mesh.test.docker;

import static com.gentics.mesh.test.ClientHelper.call;
import static org.junit.Assert.assertEquals;

import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;

import com.gentics.mesh.core.rest.user.UserListResponse;

import io.vertx.core.Vertx;

@Ignore
public class MeshDockerServerTest {

	@ClassRule
	public static MeshDockerServer server = new MeshDockerServer("gentics/mesh:0.10.0", "dummy", true, Vertx.vertx(), null, null);

	@Test
	public void testDockerImage() {
		UserListResponse response = call(() -> server.getMeshClient().findUsers());
		assertEquals(2, response.getData().size());
	}

}

Disable test which is not yet working on CI


/*
 *  Copyright 2015 Eric F. Savage, code@efsavage.com
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.ajah.rest.api.model.relay.user;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
 * @author Eric F. Savage, code@efsavage.com.
 */
@JsonInclude(Include.NON_NULL)
public class UserNameRelay {

	public String first;
	public String middle;
	public String last;
	public String suffix;
	public String display;
	public String firstName;
	public String middleName;
	public String lastName;
	public String displayName;

}

/*
 *  Copyright 2015 Eric F. Savage, code@efsavage.com
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.ajah.rest.api.model.relay.user;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
 * @author Eric F. Savage,
 *         code@efsavage.com.
 */
@JsonInclude(Include.NON_NULL)
public class UserNameRelay {

	public String first;
	public String middle;
	public String last;
	public String suffix;
	public String display;
	@Deprecated
	public String firstName;
	@Deprecated
	public String middleName;
	@Deprecated
	public String lastName;
	@Deprecated
	public String displayName;

}

Mark redundant properties as deprecated


package info.u_team.u_team_test.entity.render;

import com.mojang.blaze3d.vertex.PoseStack;

import info.u_team.u_team_test.TestMod;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.ZombieRenderer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.monster.Zombie;

public class TestLivingEntityRenderer extends ZombieRenderer {

	private static final ResourceLocation TEXTURE = new ResourceLocation(TestMod.MODID, "textures/entity/test_living/test_living.png");

	public TestLivingEntityRenderer(EntityRendererProvider.Context renderManager) {
		super(renderManager);
	}

	@Override
	protected void scale(Zombie zombie, PoseStack matrixStack, float partialTickTime) {
		matrixStack.scale(1.8F, 1.8F, 1.8F);
		super.scale(zombie, matrixStack, partialTickTime);
	}

	@Override
	public ResourceLocation getTextureLocation(Zombie entity) {
		return TEXTURE;
	}

}

package info.u_team.u_team_test.entity.render;

import com.mojang.blaze3d.vertex.PoseStack;

import info.u_team.u_team_test.TestMod;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.ZombieRenderer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.monster.Zombie;

public class TestLivingEntityRenderer extends ZombieRenderer {

	private static final ResourceLocation TEXTURE = new ResourceLocation(TestMod.MODID, "textures/entity/test_living/test_living.png");

	public TestLivingEntityRenderer(EntityRendererProvider.Context renderManager) {
		super(renderManager);
	}

	@Override
	protected void scale(Zombie zombie, PoseStack poseStack, float partialTickTime) {
		poseStack.scale(1.8F, 1.8F, 1.8F);
		super.scale(zombie, poseStack, partialTickTime);
	}

	@Override
	public ResourceLocation getTextureLocation(Zombie entity) {
		return TEXTURE;
	}

}

Replace matrixStack in test living renderer


package org.wikipedia.onboarding;

import org.wikipedia.settings.Prefs;

public final class PrefsOnboardingStateMachine implements OnboardingStateMachine {
    private static final PrefsOnboardingStateMachine INSTANCE = new PrefsOnboardingStateMachine();

    private final boolean initialTocTutorialEnabled = Prefs.isTocTutorialEnabled();

    public static PrefsOnboardingStateMachine getInstance() {
        return INSTANCE;
    }

    @Override
    public boolean isTocTutorialEnabled() {
        return Prefs.isTocTutorialEnabled();
    }

    @Override
    public void setTocTutorial() {
        Prefs.setTocTutorialEnabled(false);
    }

    @Override
    public boolean isSelectTextTutorialEnabled() {
        return !initialTocTutorialEnabled && Prefs.isSelectTextTutorialEnabled();
    }

    @Override
    public void setSelectTextTutorial() {
        Prefs.setSelectTextTutorialEnabled(false);
    }

    @Override
    public boolean isShareTutorialEnabled() {
        return !initialTocTutorialEnabled
                && !isSelectTextTutorialEnabled()
                && Prefs.isShareTutorialEnabled();
    }

    @Override
    public void setShareTutorial() {
        Prefs.setShareTutorialEnabled(false);
    }

    private PrefsOnboardingStateMachine() { }
}

package org.wikipedia.onboarding;

import org.wikipedia.settings.Prefs;
import java.util.concurrent.TimeUnit;

public final class PrefsOnboardingStateMachine implements OnboardingStateMachine {
    private static final PrefsOnboardingStateMachine INSTANCE = new PrefsOnboardingStateMachine();
    private static final long MIN_MINUTES_PER_TUTORIAL = 1;

    private long millisSinceLastTutorial;

    public static PrefsOnboardingStateMachine getInstance() {
        return INSTANCE;
    }

    @Override
    public boolean isTocTutorialEnabled() {
        // don't care about time since last tutorial here, since the ToC tooltip
        // is always the first one shown.
        return Prefs.isTocTutorialEnabled();
    }

    @Override
    public void setTocTutorial() {
        Prefs.setTocTutorialEnabled(false);
        updateTimeSinceLastTutorial();
    }

    @Override
    public boolean isSelectTextTutorialEnabled() {
        return minutesSinceLastTutorial() >= MIN_MINUTES_PER_TUTORIAL
               && !Prefs.isTocTutorialEnabled() && Prefs.isSelectTextTutorialEnabled();
    }

    @Override
    public void setSelectTextTutorial() {
        Prefs.setSelectTextTutorialEnabled(false);
        updateTimeSinceLastTutorial();
    }

    @Override
    public boolean isShareTutorialEnabled() {
        // don't care about time since last tutorial here, since the share tooltip is
        // tied to the highlight action.
        return !Prefs.isTocTutorialEnabled()
                && !isSelectTextTutorialEnabled()
                && Prefs.isShareTutorialEnabled();
    }

    @Override
    public void setShareTutorial() {
        Prefs.setShareTutorialEnabled(false);
        updateTimeSinceLastTutorial();
    }

    private void updateTimeSinceLastTutorial() {
        millisSinceLastTutorial = System.currentTimeMillis();
    }

    private long minutesSinceLastTutorial() {
        return TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - millisSinceLastTutorial);
    }

    private PrefsOnboardingStateMachine() { }
}

Improve sequencing of ToC and Text-highlight tooltips.


/**
 * Copyright (C) 2015 Lable (info@lable.nl)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.lable.oss.dynamicconfig.core;

import org.junit.Test;

import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class InstanceLocalSettingsTest {
    @Test
    public void setAppNameTest() {
        InstanceLocalSettings.INSTANCE.setAppName("XXX");
        assertThat(InstanceLocalSettings.INSTANCE.getAppName(), is("XXX"));
    }

    @Test
    public void getAppNameUnsetTest() {
        assertThat(InstanceLocalSettings.INSTANCE.getAppName(), is(nullValue()));
    }
}

Add missing license header to test


// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.zookeeper.cli;

import com.yahoo.vespa.zookeeper.client.ZkClientConfigBuilder;
import org.apache.zookeeper.ZooKeeperMain;

import java.io.IOException;

/**
 * @author bjorncs
 */
public class Main {
    public static void main(String[] args) throws IOException, InterruptedException {
        new ZkClientConfigBuilder()
                .toConfigProperties()
                .forEach(System::setProperty);
        ZooKeeperMain.main(args);
    }
}

// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.zookeeper.cli;

import com.yahoo.vespa.zookeeper.client.ZkClientConfigBuilder;
import org.apache.zookeeper.ZooKeeperMain;
import org.slf4j.impl.SimpleLogger;

import java.io.IOException;

/**
 * @author bjorncs
 */
public class Main {

    static {
        System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "WARN");
    }

    public static void main(String[] args) throws IOException, InterruptedException {
        new ZkClientConfigBuilder()
                .toConfigProperties()
                .forEach(System::setProperty);
        ZooKeeperMain.main(args);
    }
}

Set default log level to WARN, to avoid excessive INFO log from ZK


package org.fxmisc.richtext.demo.richtext;

import java.util.Optional;

import org.fxmisc.richtext.model.SegmentOps;

public class LinkedImageOps<S> implements SegmentOps<LinkedImage<S>, S> {

    private final EmptyLinkedImage<S> emptySeg = new EmptyLinkedImage<>();

    @Override
    public int length(LinkedImage<S> seg) {
        return seg == emptySeg ? 0 : 1;
    }

    @Override
    public char charAt(LinkedImage<S> seg, int index) {
        return seg == emptySeg ? '\0' : '\ufffc';
    }

    @Override
    public String getText(LinkedImage<S> seg) {
        return seg == emptySeg ? "" : "\ufffc";
    }

    @Override
    public LinkedImage<S> subSequence(LinkedImage<S> seg, int start, int end) {
        if (start < 0) {
            throw new IllegalArgumentException("Start cannot be negative. Start = " + start);
        }
        if (end > length(seg)) {
            throw new IllegalArgumentException("End cannot be greater than segment's length");
        }
        return start == 0 && end == 1
                ? seg
                : emptySeg;
    }

    @Override
    public LinkedImage<S> subSequence(LinkedImage<S> seg, int start) {
        if (start < 0) {
            throw new IllegalArgumentException("Start cannot be negative. Start = " + start);
        }
        return start == 0
                ? seg
                : emptySeg;
    }

    @Override
    public S getStyle(LinkedImage<S> seg) {
        return seg.getStyle();
    }

    @Override
    public LinkedImage<S> setStyle(LinkedImage<S> seg, S style) {
        return seg == emptySeg ? emptySeg : seg.setStyle(style);
    }

    @Override
    public Optional<LinkedImage<S>> join(LinkedImage<S> currentSeg, LinkedImage<S> nextSeg) {
        return Optional.empty();
    }

    @Override
    public LinkedImage<S> createEmpty() {
        return emptySeg;
    }
}

package org.fxmisc.richtext.demo.richtext;

import org.fxmisc.richtext.model.NodeSegmentOpsBase;

public class LinkedImageOps<S> extends NodeSegmentOpsBase<LinkedImage<S>, S> {

    public LinkedImageOps() {
        super(new EmptyLinkedImage<>());
    }

    @Override
    public S realGetStyle(LinkedImage<S> linkedImage) {
        return linkedImage.getStyle();
    }

    @Override
    public LinkedImage<S> realSetStyle(LinkedImage<S> linkedImage, S style) {
        return linkedImage.setStyle(style);
    }

}

Extend base class to reduce boilerplate code


import static org.junit.Assert.*;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class TetrisTest
{
    @Test
    public void shouldReturnTwo()
    {
        //assertEquals(Tetris.returnTwo(), 2);
    }
}

import static org.junit.Assert.*;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class TetrisTest
{

}

Add test for the main