package uk.co.ticklethepanda.carto.apps.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import uk.co.ticklethepanda.carto.core.projection.Projector;

@Configuration
public class ProjectionConfig {

    @Bean(name = "projector")
    public Projector projector(
            @Value("${location.history.heatmap.projector}") String projectorName
    ) throws ClassNotFoundException, IllegalAccessException, InstantiationException {

        Class<?> projectorClass = Class.forName(projectorName);

        Object projector = projectorClass.newInstance();

        if (!(projector instanceof Projector)) {
            throw new IllegalArgumentException("\"location.history.heatmap.projector\" must be a type of Projector");
        }

        return (Projector) projector;

    }
}

package uk.co.ticklethepanda.carto.apps.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import uk.co.ticklethepanda.carto.core.projection.Projector;

import java.lang.reflect.InvocationTargetException;

@Configuration
public class ProjectionConfig {

    @Bean(name = "projector")
    public Projector projector(
            @Value("${location.history.heatmap.projector}") String projectorName
    ) throws ClassNotFoundException,
            IllegalAccessException,
            InstantiationException,
            NoSuchMethodException,
            InvocationTargetException {

        Class<?> projectorClass = Class.forName(projectorName);

        Object projector = projectorClass.getDeclaredConstructor().newInstance();

        if (!(projector instanceof Projector)) {
            throw new IllegalArgumentException("\"location.history.heatmap.projector\" must be a type of Projector");
        }

        return (Projector) projector;

    }
}

Use non-deprecated new instance method


package de.haw.vs.nameservice.connectionhandler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class Server implements IServer {

    private ServerSocket serverSocket;
    private volatile boolean stopping;
    private final Logger log = LoggerFactory.getLogger(Server.class);
    private final int maxConcurrentConnections = 30;
    private final Executor threadPool = Executors.newFixedThreadPool(maxConcurrentConnections);

    @Override
    public void initServer(int port) {
        try {
            serverSocket = new ServerSocket(port);
            this.stopping = false;
        } catch (IOException e) {
            this.stopping = true;
            log.error("Could not start server at port: " + String.valueOf(port), e);
        }
    }

    @Override
    public void run() {
        log.info("Started server");
        while (!stopping) {
            try {
                Socket clientSocket = serverSocket.accept();
                IClientRequestHandler clientRequest = new ClientRequestHandler(clientSocket);
                threadPool.execute(clientRequest);
            } catch (IOException e) {
                log.warn("Error while client tried to connect", e);
            }
        }
        try {
            serverSocket.close();
        } catch (IOException e) {
            log.warn("Could not close server socket");
        }
        log.info("Stopped server");
    }

    public boolean isStopping() {
        return stopping;
    }

    public void stop() {
        this.stopping = true;
    }
}

package de.haw.vs.nameservice.connectionhandler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Server implements IServer {

    private ServerSocket serverSocket;
    private volatile boolean stopping;
    private final Logger log = LoggerFactory.getLogger(Server.class);
    private final int maxConcurrentConnections = 30;
    private final ExecutorService threadPool = Executors.newFixedThreadPool(maxConcurrentConnections);

    @Override
    public void initServer(int port) {
        try {
            serverSocket = new ServerSocket(port);
            this.stopping = false;
        } catch (IOException e) {
            this.stopping = true;
            log.error("Could not start server at port: " + String.valueOf(port), e);
        }
    }

    @Override
    public void run() {
        log.info("Started server");
        while (!stopping) {
            try {
                Socket clientSocket = serverSocket.accept();
                IClientRequestHandler clientRequest = new ClientRequestHandler(clientSocket);
                threadPool.submit(clientRequest);
            } catch (IOException e) {
                log.warn("Error while client tried to connect", e);
            }
        }
        try {
            serverSocket.close();
        } catch (IOException e) {
            log.warn("Could not close server socket");
        }
        log.info("Stopped server");
    }

    public boolean isStopping() {
        return stopping;
    }

    public void stop() {
        this.stopping = true;
    }
}

Use ExecutorService instead of Executor


package io.joss.graphql.jersey.resource;

import java.util.List;

import io.joss.graphql.jersey.auth.RegistryAuthValue;
import lombok.ToString;

@ToString
public class UnverifiedCredentials
{

  private List<RegistryAuthValue> values;

  public UnverifiedCredentials(List<RegistryAuthValue> values)
  {
    this.values = values;
  }

}

package io.joss.graphql.jersey.resource;

import java.util.List;

import io.joss.graphql.jersey.auth.RegistryAuthValue;
import lombok.ToString;

@ToString
public class UnverifiedCredentials
{

  private List<RegistryAuthValue> values;

  public UnverifiedCredentials(List<RegistryAuthValue> values)
  {
    this.values = values;
  }

  public List<RegistryAuthValue> values()
  {
    return values;
  }

}

Add getter for unverified credentials


package edu.northwestern.bioinformatics.studycalendar.web.template;

import edu.northwestern.bioinformatics.studycalendar.web.ReturnSingleObjectController;
import edu.northwestern.bioinformatics.studycalendar.domain.Arm;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.AccessControl;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.StudyCalendarProtectionGroup;

/**
 * @author Rhett Sutphin
 */
@AccessControl(protectionGroups = StudyCalendarProtectionGroup.STUDY_COORDINATOR)
public class SelectArmController extends ReturnSingleObjectController<Arm> {
    public SelectArmController() {
        setParameterName("arm");
        setViewName("template/ajax/selectArm");
    }

    @Override
    protected Object wrapObject(Arm loaded) {
        return new ArmTemplate(loaded);
    }
}

package edu.northwestern.bioinformatics.studycalendar.web.template;

import edu.northwestern.bioinformatics.studycalendar.web.ReturnSingleObjectController;
import edu.northwestern.bioinformatics.studycalendar.domain.Arm;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.AccessControl;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.StudyCalendarProtectionGroup;

/**
 * @author Rhett Sutphin
 */
@AccessControl(protectionGroups = StudyCalendarProtectionGroup.BASE)
public class SelectArmController extends ReturnSingleObjectController<Arm> {
    public SelectArmController() {
        setParameterName("arm");
        setViewName("template/ajax/selectArm");
    }

    @Override
    protected Object wrapObject(Arm loaded) {
        return new ArmTemplate(loaded);
    }
}

Use base because everyone can use the template view


package fr.paris10.projet.assogenda.assogenda.util;

/**
 * Created by valentin on 22/01/17.
 */

public class Period {
    private int begin;
    private int end;

    public Period(int begin, int end) throws PeriodException{
        if(begin > end || begin == end)
            throw new PeriodException("Begin must be lower or different than end");
        if(begin < 0 || begin > 24 || end < 0 || begin > 24 || begin > end)
            throw new PeriodException("A period can't exceed 24hours or have negative values");
        this.begin = begin;
        this.end = end;
    }
}

package fr.paris10.projet.assogenda.assogenda.util;

/**
 * Created by valentin on 22/01/17.
 */

public class Period {
    private int begin;
    private int end;

    public Period(int begin, int end) throws PeriodException {
        if (begin > end || begin == end)
            throw new PeriodException("Begin must be inferior to the end of the period");
        if (begin < 0 || begin > 24)
            throw new PeriodException("Begin of period can't be negative of exceed 24 hours");
        if (end < 0 || end > 24)
            throw new PeriodException("End of a period can't be negative or exceed 24 hours");
        this.begin = begin;
        this.end = end;
    }
}

Fix constructor to identify wrong period


package info.izumin.android.bletia;

import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;

import org.jdeferred.Promise;

import info.izumin.android.bletia.action.Action;
import info.izumin.android.bletia.wrapper.BluetoothGattWrapper;

/**
 * Created by izumin on 9/14/15.
 */
public class BleMessageThread extends Handler {

    private static final int DELAY_MILLIS = 10;

    private final HandlerThread mHandlerThread;
    private final BluetoothGattWrapper mGattWrapper;
    private final BleActionStore mActionStore;

    public BleMessageThread(HandlerThread handlerThread, BluetoothGattWrapper gattWrapper, BleActionStore actionStore) {
        super(handlerThread.getLooper());
        mHandlerThread = handlerThread;
        mGattWrapper = gattWrapper;
        mActionStore = actionStore;
    }

    public void stop() {
        mHandlerThread.quitSafely();
    }

    public <T> Promise<T, BletiaException, Object> execute(Action<T> action) {
        mActionStore.enqueue(action);
        dispatchMessage(action.obtainMessage());

        return action.getDeferred().promise();
    }

    @Override
    public void handleMessage(Message msg) {
        Action.Type type = Action.Type.valueOf(msg.what);

        if (mActionStore.isRunning(type)) {
            sendMessageDelayed(msg, DELAY_MILLIS);
        } else {
            mActionStore.execute(type, mGattWrapper);
        }
    }
}

package info.izumin.android.bletia;

import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;

import org.jdeferred.Promise;

import info.izumin.android.bletia.action.Action;
import info.izumin.android.bletia.wrapper.BluetoothGattWrapper;

/**
 * Created by izumin on 9/14/15.
 */
public class BleMessageThread extends Handler {

    private static final int DELAY_MILLIS = 10;

    private final HandlerThread mHandlerThread;
    private final BluetoothGattWrapper mGattWrapper;
    private final BleActionStore mActionStore;

    public BleMessageThread(HandlerThread handlerThread, BluetoothGattWrapper gattWrapper, BleActionStore actionStore) {
        super(handlerThread.getLooper());
        mHandlerThread = handlerThread;
        mGattWrapper = gattWrapper;
        mActionStore = actionStore;
    }

    public void stop() {
        mHandlerThread.quitSafely();
    }

    public <T> Promise<T, BletiaException, Object> execute(Action<T> action) {
        mActionStore.enqueue(action);
        dispatchMessage(action.obtainMessage());

        return action.getDeferred().promise();
    }

    @Override
    public void handleMessage(Message msg) {
        Action.Type type = Action.Type.valueOf(msg.what);

        if (mActionStore.isRunning(type)) {
            Message delayed = obtainMessage();
            delayed.copyFrom(msg);
            sendMessageDelayed(delayed, DELAY_MILLIS);
        } else {
            mActionStore.execute(type, mGattWrapper);
        }
    }
}

Fix send message delayed when the message has conflict


package com.infonuascape.osrshelper.tracker.cml;

import com.android.volley.Request;
import com.infonuascape.osrshelper.utils.exceptions.PlayerNotFoundException;
import com.infonuascape.osrshelper.utils.http.NetworkStack;

import java.io.IOException;
import java.net.URLEncoder;

/**
 * This class contains a single method that updates a user on RuneTracker. This
 * is defined as calling an HTTP endpoint which adds a point of data in the
 * user's stats history table.
 *
 * @author Cynthia of irc.rscript.org
 */
public class Updater {
	/**
	 * Updates the given user on RuneTracker.
	 *
	 * @param user
	 *            Name of the user to update. Since 2009-10-01, this is the
	 *            display name of the user, not his or her login name.
	 * @throws IOException
	 *             if the HTTP endpoint connection needed to update the
	 *             user throws <tt>IOException</tt>
	 * @throws PlayerNotFoundException
	 */
	public static void perform(final String user) throws IOException, PlayerNotFoundException {
		android.util.Log.i("Updater", "Hey! I'm updating!");
		String connectionString = "http://runetracker.org/updateUser.php?user=" + URLEncoder.encode(user, "utf-8");
		NetworkStack.getInstance().performRequest(connectionString, Request.Method.GET);
	}
}

package com.infonuascape.osrshelper.tracker.cml;

import com.android.volley.Request;
import com.infonuascape.osrshelper.utils.exceptions.PlayerNotFoundException;
import com.infonuascape.osrshelper.utils.http.NetworkStack;

import java.io.IOException;
import java.net.URLEncoder;

public class Updater {

	public static void perform(final String user) throws IOException, PlayerNotFoundException {
		android.util.Log.i("Updater", "Hey! I'm updating!");
		String connectionString = "https://crystalmathlabs.com/tracker/api.php?type=update&player=" + URLEncoder.encode(user, "utf-8");
		NetworkStack.getInstance().performRequest(connectionString, Request.Method.GET);
	}
}

Fix CML Update to proper API endpoint


package com.servinglynk.hmis.warehouse.core.model;

import java.util.ArrayList;
import java.util.List;
import com.servinglynk.hmis.warehouse.PaginatedModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;

@JsonRootName("rhybcpStatuses")
public class Rhybcpstatuses extends PaginatedModel{

       @JsonProperty("rhybcpstatuses")
       List<Rhybcpstatus>rhybcpstatuses = new ArrayList<Rhybcpstatus>();
       public List<Rhybcpstatus> getRhybcpstatuses() {
           return rhybcpstatuses;
       }

        public void setRhybcpstatuses(List<Rhybcpstatus> rhybcpstatuses) {
           this.rhybcpstatuses = rhybcpstatuses;
       }

       public void addRhybcpstatus(Rhybcpstatus rhybcpstatus) {
           this.rhybcpstatuses.add(rhybcpstatus);
       }
 }

package com.servinglynk.hmis.warehouse.core.model;

import java.util.ArrayList;
import java.util.List;
import com.servinglynk.hmis.warehouse.PaginatedModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;

@JsonRootName("rhybcpStatuses")
public class Rhybcpstatuses extends PaginatedModel{

       @JsonProperty("rhybcpStatuses")
       List<Rhybcpstatus>rhybcpstatuses = new ArrayList<Rhybcpstatus>();
       public List<Rhybcpstatus> getRhybcpstatuses() {
           return rhybcpstatuses;
       }

        public void setRhybcpstatuses(List<Rhybcpstatus> rhybcpstatuses) {
           this.rhybcpstatuses = rhybcpstatuses;
       }

       public void addRhybcpstatus(Rhybcpstatus rhybcpstatus) {
           this.rhybcpstatuses.add(rhybcpstatus);
       }
 }

Fix rhybcpStatuses in the get response


/*
 * Copyright 2015-2016 Hewlett-Packard 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.hod.client.api.authentication.tokeninformation;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.hp.autonomy.hod.client.api.userstore.user.Account;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.UUID;

/**
 * Information about the user component of an authentication token.
 */
@Data
public class UserInformation implements Serializable {
    private static final long serialVersionUID = -2610523494602694306L;

    /**
     * @return The UUID of the user
     */
    private final UUID uuid;

    /**
     * @return Information about the mechanism used to authenticate the user
     */
    private final AuthenticationInformation authentication;

    /**
     * @return Groups directly associated with the user
     */
    private final List<String> directGroups;

    /**
     * @return Groups either directly or transitively associated with the user
     */
    private final List<String> groups;

    /**
     * @return Accounts associated with the user
     */
    private final List<Account> accounts;

    public UserInformation(
        @JsonProperty("uuid") final UUID uuid,
        @JsonProperty("auth") final AuthenticationInformation authentication,
        @JsonProperty("direct_groups") final List<String> directGroups,
        @JsonProperty("groups") final List<String> groups,
        @JsonProperty("accounts") final List<Account> accounts
    ) {
        this.uuid = uuid;
        this.authentication = authentication;
        this.directGroups = directGroups;
        this.groups = groups;
        this.accounts = accounts;
    }
}

/*
 * Copyright 2015-2016 Hewlett-Packard 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.hod.client.api.authentication.tokeninformation;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.hp.autonomy.hod.client.api.userstore.user.Account;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.UUID;

/**
 * Information about the user component of an authentication token.
 */
@Data
public class UserInformation implements Serializable {
    private static final long serialVersionUID = -2610523494602694306L;

    /**
     * @return The UUID of the user
     */
    private final UUID uuid;

    /**
     * @return Information about the mechanism used to authenticate the user
     */
    private final AuthenticationInformation authentication;

    /**
     * @return Accounts associated with the user
     */
    private final List<Account> accounts;

    public UserInformation(
        @JsonProperty("uuid") final UUID uuid,
        @JsonProperty("auth") final AuthenticationInformation authentication,
        @JsonProperty("accounts") final List<Account> accounts
    ) {
        this.uuid = uuid;
        this.authentication = authentication;
        this.accounts = accounts;
    }
}

Fix user information parsing that had a different response format than expected - for now remove group info


package com.proxerme.library.util;

import android.support.test.InstrumentationRegistry;

import com.proxerme.library.connection.ProxerConnection;

import org.junit.AfterClass;
import org.junit.BeforeClass;

import java.io.IOException;

import okhttp3.mockwebserver.MockWebServer;

/**
 * Base class for all {@link com.proxerme.library.connection.ProxerRequest} subclass tests.
 *
 * @author Ruben Gees
 */
public class RequestTest {

    protected static MockWebServer server = new MockWebServer();
    protected static ProxerConnection connection = new ProxerConnection.Builder("test",
            InstrumentationRegistry.getContext()).build();

    protected RequestTest() {

    }

    @BeforeClass
    public static void setUpServer() throws IOException {
        server.start();
    }

    @AfterClass
    public static void tearDownServer() throws IOException {
        server.shutdown();
    }
}

package com.proxerme.library.util;

import android.support.test.InstrumentationRegistry;

import com.proxerme.library.connection.ProxerConnection;

import org.junit.After;
import org.junit.Before;

import java.io.IOException;

import okhttp3.mockwebserver.MockWebServer;

/**
 * Base class for all {@link com.proxerme.library.connection.ProxerRequest} subclass tests.
 *
 * @author Ruben Gees
 */
public class RequestTest {

    protected MockWebServer server;
    protected ProxerConnection connection;

    protected RequestTest() {

    }

    @Before
    public void setUp() throws IOException {
        server = new MockWebServer();
        connection = new ProxerConnection.Builder("test",
                InstrumentationRegistry.getContext()).build();

        server.start();
    }

    @After
    public void tearDown() throws IOException {
        server.shutdown();
    }
}

Fix tests by constructing a new server and connection in setup


// Copyright (C) 2009 The Android Open Source Project
//
// 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.googlesource.gerrit.plugins.replication;

import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupMembership;

public class RemoteSiteUser extends CurrentUser {
  private final GroupMembership effectiveGroups;

  public RemoteSiteUser(GroupMembership authGroups) {
    effectiveGroups = authGroups;
  }

  @Override
  public GroupMembership getEffectiveGroups() {
    return effectiveGroups;
  }
}

// Copyright (C) 2009 The Android Open Source Project
//
// 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.googlesource.gerrit.plugins.replication;

import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupMembership;

public class RemoteSiteUser extends CurrentUser {
  private final GroupMembership effectiveGroups;

  public RemoteSiteUser(GroupMembership authGroups) {
    effectiveGroups = authGroups;
  }

  @Override
  public GroupMembership getEffectiveGroups() {
    return effectiveGroups;
  }

  @Override
  public Object getCacheKey() {
    // Never cache a remote user
    return new Object();
  }
}

Revert "Adjust to changes in Gerrit core"


package net.openhft.chronicle.core.time;

public class BackgroundTimeProviderMain {
    public static void main(String[] args) throws InterruptedException {
        int under = 0, over = 0;
        for (int i = 0; i < 6_000; i++) {
            BackgroundTimeProvider tp = BackgroundTimeProvider.INSTANCE;
            long nowMS;
            long nowNS;
            if (i % 2 == 0) {
                nowMS = System.currentTimeMillis();
                nowNS = tp.currentTimeNanos();
            } else {
                nowNS = tp.currentTimeNanos();
                nowMS = System.currentTimeMillis();
            }
            long diff = nowNS - nowMS * 1000000;
            if (diff < 0) {
                under += 1 + (diff / -1e4);
            }
            if (diff > 1e6) {
                over += 1 + (diff - 1e6) / 1e4;
            }
            Thread.sleep(1);
        }
        System.out.println("under: " + under + ", over: " + over);
    }

}

package net.openhft.chronicle.core.time;

public class BackgroundTimeProviderMain {
    public static void main(String[] args) throws InterruptedException {
        int under = 0, over = 0;
        for (int i = 0; i < 6_000; i++) {
            BackgroundTimeProvider tp = BackgroundTimeProvider.INSTANCE;
            long nowMS;
            long nowNS;
            if (i % 2 == 0) {
                nowMS = System.currentTimeMillis();
                nowNS = tp.currentTimeNanos();
            } else {
                nowNS = tp.currentTimeNanos();
                nowMS = System.currentTimeMillis();
            }
            long diff = nowNS - nowMS * 1000000;
            if (diff < -1e5 || diff > 11e5)
                System.out.println("diff: " + diff);
            if (diff < 0) {
                under += 1 + (diff / -1e4);
            }
            if (diff > 1e6) {
                over += 1 + (diff - 1e6) / 1e4;
            }
            Thread.sleep(1);
        }
        System.out.println("under: " + under + ", over: " + over);
    }

}

Add warning if a MethodReader tries to read for an overloaded interface.


/**
 *
 * Defines a set of themes for the maps
 * in the arena.

 *
 *
 *

 * The themes are:
 *

 *
 Continental
 *
 Artical
 *
 Desertic
 *
 Tropical
 *

 *
 * @see Weather
 */
package random;

/**
 *
 * Defines a set of themes for the maps
 * in the arena.

 *
 *
 *

 * The themes are:
 *

 *
 Continental
 *
 Artical
 *
 Desertic
 *
 Tropical
 *

 */
package random;

Fix in link at @see


package edu.northwestern.bioinformatics.studycalendar.dao;

import edu.northwestern.bioinformatics.studycalendar.domain.Period;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Rhett Sutphin
 */
@Transactional(readOnly = true)
public class PeriodDao extends StudyCalendarMutableDomainObjectDao<Period> {
    @Override
    public Class<Period> domainClass() {
        return Period.class;
    }

    public void evict(Period period) {
        getHibernateTemplate().evict(period);
    }

    public void delete(Period period) {
        getHibernateTemplate().delete(period);
    }
}

package edu.northwestern.bioinformatics.studycalendar.dao;

import edu.northwestern.bioinformatics.studycalendar.domain.Period;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Rhett Sutphin
 */
@Transactional(readOnly = true)
public class PeriodDao extends StudyCalendarMutableDomainObjectDao<Period> {
    @Override
    public Class<Period> domainClass() {
        return Period.class;
    }

    /**
    * To manage caching of a period, this method will remove the period specified from hibernate's first level cache
    *
    * @param  period the period to remove from the cache
    */
    public void evict(Period period) {
        getHibernateTemplate().evict(period);
    }

    /**
    * Deletes a period
    *
    * @param  period the period to delete
    */
    public void delete(Period period) {
        getHibernateTemplate().delete(period);
    }
}

Add javadoc to period dao.


package de.gesellix.gradle.docker.testutil;

import de.gesellix.docker.client.DockerClient;

import java.util.Objects;

public class TestImage {

  private final DockerClient dockerClient;
  private final String repository;
  private final String tag;
  private final boolean isWindows;

  public TestImage(DockerClient dockerClient) {
    this.dockerClient = dockerClient;

    this.isWindows = Objects.requireNonNull(dockerClient.version().getContent().getOs()).equalsIgnoreCase("windows");
    this.repository = "gesellix/echo-server";
    this.tag = isWindows ? "os-windows" : "os-linux";

    // TODO consider NOT calling prepare inside the constructor
    prepare();
  }

  public void prepare() {
    dockerClient.pull(null, null, getImageName(), getImageTag());
  }

  public boolean isWindows() {
    return isWindows;
  }

  public String getImageWithTag() {
    return getImageName() + ":" + getImageTag();
  }

  public String getImageName() {
    return repository;
  }

  public String getImageTag() {
    return tag;
  }
}

package de.gesellix.gradle.docker.testutil;

import de.gesellix.docker.client.DockerClient;

import java.util.Objects;

public class TestImage {

  private final DockerClient dockerClient;
  private final String repository;
  private final String tag;
  private final boolean isWindows;

  public TestImage(DockerClient dockerClient) {
    this.dockerClient = dockerClient;

    this.isWindows = Objects.requireNonNull(dockerClient.version().getContent().getOs()).equalsIgnoreCase("windows");
    this.repository = "gesellix/echo-server";
    this.tag = "2022-04-08T22-27-00";

    // TODO consider NOT calling prepare inside the constructor
    prepare();
  }

  public void prepare() {
    dockerClient.pull(null, null, getImageName(), getImageTag());
  }

  public boolean isWindows() {
    return isWindows;
  }

  public String getImageWithTag() {
    return getImageName() + ":" + getImageTag();
  }

  public String getImageName() {
    return repository;
  }

  public String getImageTag() {
    return tag;
  }
}

Use the multi-platform gesellix/echo-server image


/*
 * Copyright 2012 The Netty Project
 *
 * The Netty Project licenses this file to you 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.jboss.netty.channel.socket;

/**
 * Internet Protocol (IP) families
 */
public enum InternetProtocolFamily {
    IPv4,
    IPv6;
}

Add a missing newline at the end of the file


package org.javarosa.core.model.utils;

import org.javarosa.core.model.trace.EvaluationTrace;
import org.javarosa.core.model.trace.EvaluationTraceReporter;
import org.javarosa.core.model.trace.StringEvaluationTraceSerializer;

/**
 * Utility functions for instrumentation in the engine
 *
 * Created by ctsims on 7/6/2017.
 */

public class InstrumentationUtils {

    /**
     * Prints out traces (if any exist) from the provided reporter with a description into sysout
     */
    public static void printAndClearTraces(EvaluationTraceReporter reporter, String description) {
        if (reporter != null) {
            if (reporter.wereTracesReported()) {
                System.out.println(description);
            }

            StringEvaluationTraceSerializer serializer = new StringEvaluationTraceSerializer();

            for (EvaluationTrace trace : reporter.getCollectedTraces()) {
                System.out.println(trace.getExpression() + ": " + trace.getValue());
                System.out.print(serializer.serializeEvaluationLevels(trace));
            }

            reporter.reset();
        }
    }
}

package org.javarosa.core.model.utils;

import org.javarosa.core.model.trace.EvaluationTrace;
import org.javarosa.core.model.trace.EvaluationTraceReporter;
import org.javarosa.core.model.trace.StringEvaluationTraceSerializer;

/**
 * Utility functions for instrumentation in the engine
 *
 * Created by ctsims on 7/6/2017.
 */

public class InstrumentationUtils {

    /**
     * Prints out traces (if any exist) from the provided reporter with a description into sysout
     */
    public static void printAndClearTraces(EvaluationTraceReporter reporter, String description) {
        if (reporter != null) {
            if (reporter.wereTracesReported()) {
                System.out.println(description);
            }

            StringEvaluationTraceSerializer serializer = new StringEvaluationTraceSerializer();

            for (EvaluationTrace trace : reporter.getCollectedTraces()) {
                System.out.println(trace.getExpression() + ": " + trace.getValue());
                System.out.print(serializer.serializeEvaluationLevels(trace));
            }

            reporter.reset();
        }
    }

    /**
     * Prints out traces (if any exist) from the provided reporter with a description into sysout
     */
    public static String collectAndClearTraces(EvaluationTraceReporter reporter, String description) {
        String returnValue = "";
        if (reporter != null) {
            if (reporter.wereTracesReported()) {
                returnValue += description + "\n";
            }

            StringEvaluationTraceSerializer serializer = new StringEvaluationTraceSerializer();

            for (EvaluationTrace trace : reporter.getCollectedTraces()) {
                returnValue += trace.getExpression() + ": " + trace.getValue()  + "\n";
                returnValue += serializer.serializeEvaluationLevels(trace);
            }

            reporter.reset();
        }
        return returnValue;
    }

}

Add a way to evaluate traces into a single string output


/*
 * Copyright (C) 2009 XStream Committers.
 * All rights reserved.
 *
 * Created on 15. August 2009 by Joerg Schaible
 */
package com.thoughtworks.xstream.io.xml;

/**
 * A XmlFriendlyNameCoder to support backward compatibility with XStream 1.1.
 *
 * @author Jörg Schaible
 * @since upcoming
 */
public class XStream11NameCoder extends XmlFriendlyNameCoder {

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeAttribute(String attributeName) {
        return attributeName;
    }

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeNode(String elementName) {
        return elementName;
    }
}

/*
 * Copyright (C) 2009 XStream Committers.
 * All rights reserved.
 *
 * The software in this package is published under the terms of the BSD
 * style license a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 *
 * Created on 15. August 2009 by Joerg Schaible
 */
package com.thoughtworks.xstream.io.xml;

/**
 * A XmlFriendlyNameCoder to support backward compatibility with XStream 1.1.
 *
 * @author Jörg Schaible
 * @since upcoming
 */
public class XStream11NameCoder extends XmlFriendlyNameCoder {

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeAttribute(String attributeName) {
        return attributeName;
    }

    /**
     * {@inheritDoc} Noop implementation that does not decode. Used for XStream 1.1
     * compatibility.
     */
    public String decodeNode(String elementName) {
        return elementName;
    }
}

Fix file headers for missing BSD license.


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.jackrabbit.oak.kernel;

import org.apache.jackrabbit.oak.NodeStoreFixture;
import org.apache.jackrabbit.oak.spi.state.NodeStore;

class AbstractKernelTest {

    protected NodeStore createNodeStore() {
        return NodeStoreFixture.MK_IMPL.createNodeStore();
    }
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.jackrabbit.oak.kernel;

import org.apache.jackrabbit.oak.NodeStoreFixture;
import org.apache.jackrabbit.oak.spi.state.NodeStore;

class AbstractKernelTest {

    protected NodeStore createNodeStore() {
        return NodeStoreFixture.SEGMENT_MK.createNodeStore();
    }
}

Use SegmentMK for testing where possible


package info.u_team.u_team_test.data.provider;

import java.util.function.BiConsumer;

import info.u_team.u_team_core.data.*;
import info.u_team.u_team_test.init.*;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootTable;

public class TestLootTablesProvider extends CommonLootTablesProvider {

	public TestLootTablesProvider(GenerationData data) {
		super(data);
	}

	@Override
	protected void registerLootTables(BiConsumer<ResourceLocation, LootTable> consumer) {
		registerBlock(TestBlocks.BASIC, addFortuneBlockLootTable(TestBlocks.BASIC.get(), TestItems.BASIC.get()), consumer);
		registerBlock(TestBlocks.BASIC_TILEENTITY, addTileEntityBlockLootTable(TestBlocks.BASIC_TILEENTITY.get()), consumer);
		registerBlock(TestBlocks.BASIC_ENERGY_CREATOR, addTileEntityBlockLootTable(TestBlocks.BASIC_ENERGY_CREATOR.get()), consumer);
		registerBlock(TestBlocks.BASIC_FLUID_INVENTORY, addTileEntityBlockLootTable(TestBlocks.BASIC_FLUID_INVENTORY.get()), consumer);
	}

}

package info.u_team.u_team_test.data.provider;

import java.util.function.BiConsumer;

import info.u_team.u_team_core.data.*;
import info.u_team.u_team_test.init.*;
import net.minecraft.loot.LootTable;
import net.minecraft.util.ResourceLocation;

public class TestLootTablesProvider extends CommonLootTablesProvider {

	public TestLootTablesProvider(GenerationData data) {
		super(data);
	}

	@Override
	protected void registerLootTables(BiConsumer<ResourceLocation, LootTable> consumer) {
		registerBlock(TestBlocks.BASIC, addFortuneBlockLootTable(TestBlocks.BASIC.get(), TestItems.BASIC.get()), consumer);
		registerBlock(TestBlocks.BASIC_TILEENTITY, addTileEntityBlockLootTable(TestBlocks.BASIC_TILEENTITY.get()), consumer);
		registerBlock(TestBlocks.BASIC_ENERGY_CREATOR, addTileEntityBlockLootTable(TestBlocks.BASIC_ENERGY_CREATOR.get()), consumer);
		registerBlock(TestBlocks.BASIC_FLUID_INVENTORY, addTileEntityBlockLootTable(TestBlocks.BASIC_FLUID_INVENTORY.get()), consumer);
	}

}

Fix import in test loot tables provider


package com.worldofbuzz.autoconfigure.spring.web.formatting.fieldannotation.barcode;

import com.worldofbuzz.autoconfigure.spring.web.validator.BarcodeValidator;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = BarcodeValidator.class)
@NotEmpty
public @interface Barcode {

    String message() default "Invalid barcode.";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}

package com.worldofbuzz.autoconfigure.spring.web.formatting.fieldannotation.barcode;

import com.worldofbuzz.autoconfigure.spring.web.validator.BarcodeValidator;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = BarcodeValidator.class)
@NotEmpty
public @interface Barcode {

    String message() default "Sorry, the barcode you've entered hasn't been recognised. Please try again.";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}

Update barcode validation error message.


package net.darkhax.bookshelf.mixin.item;

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Item.class)
public interface AccessorItem {

    @Mutable
    @Accessor("category")
    void bookshelf$setCreativeTab(CreativeModeTab tab);
}

package net.darkhax.bookshelf.mixin.item;

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Item.class)
public interface AccessorItem {

    @Mutable
    @Accessor("category")
    void bookshelf$setCreativeTab(CreativeModeTab tab);

    @Mutable
    @Accessor("craftingRemainingItem")
    void bookshelf$setCraftingRemainder(Item item);
}

Allow mods to change the remainder crafting item after the item has been initialized.


package com.codeaffine.extras.workingset.internal;

import static org.junit.Assert.assertNotNull;

import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.junit.Test;

import com.codeaffine.extras.workingset.internal.Images;

public class ImagesPDETest {

  @Test
  public void testRegisteredImages() throws IllegalAccessException {
    for( String constantValue : getConstantValues() ) {
      checkImageDescriptor( constantValue );
    }
  }

  private static void checkImageDescriptor( String constantValue ) {
    ImageDescriptor descriptor = Images.getImageDescriptor( constantValue );
    assertNotNull( "No image descriptor registered for: " + constantValue, descriptor );
    Image image = descriptor.createImage( false );
    assertNotNull( "Image descriptor does not return image: " + constantValue, image );
    image.dispose();
  }

  private static String[] getConstantValues() throws IllegalAccessException {
    List<String> constantValues = new LinkedList<>();
    Field[] declaredFields = Images.class.getDeclaredFields();
    for( Field constant : declaredFields ) {
      constantValues.add( ( String )constant.get( null ) );
    }
    return constantValues.toArray( new String[ constantValues.size() ] );
  }
}

package com.codeaffine.extras.workingset.internal;

import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
import static org.junit.Assert.assertNotNull;

import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.junit.Test;

public class ImagesPDETest {

  @Test
  public void testRegisteredImages() throws IllegalAccessException {
    for( String constantValue : getConstantValues() ) {
      checkImageDescriptor( constantValue );
    }
  }

  private static void checkImageDescriptor( String constantValue ) {
    ImageDescriptor descriptor = Images.getImageDescriptor( constantValue );
    assertNotNull( "No image descriptor registered for: " + constantValue, descriptor );
    Image image = descriptor.createImage( false );
    assertNotNull( "Image descriptor does not return image: " + constantValue, image );
    image.dispose();
  }

  private static String[] getConstantValues() throws IllegalAccessException {
    List<String> constantValues = new LinkedList<>();
    Field[] declaredFields = Images.class.getDeclaredFields();
    for( Field declaredField : declaredFields ) {
      if( isStatic( declaredField.getModifiers() ) && isPublic( declaredField.getModifiers() ) ) {
        constantValues.add( ( String )declaredField.get( null ) );
      }
    }
    return constantValues.toArray( new String[ constantValues.size() ] );
  }
}

Work around occasionally thrown IllegalAccessException


package com.github.googlei18n.tachyfont;

import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class TachyFontServlet extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    String jarFilename = "fonts/noto/sans/NotoSansJP-Thin_subset_smp.TachyFont.jar";
    JarFile jarFile = new JarFile("WEB-INF/" + jarFilename);
    resp.getWriter().println("Jar entries in " + jarFilename + ":");
    Enumeration<JarEntry> enumEntries = jarFile.entries();
    resp.getWriter().println("jar file:");
    while (enumEntries.hasMoreElements()) {
      JarEntry jarEntry = enumEntries.nextElement();
      resp.getWriter().println("  " + jarEntry.getName());
    }

    JarEntry base = jarFile.getJarEntry("base");
    JarEntry closure_data = jarFile.getJarEntry("closure_data");
    JarEntry closure_idx = jarFile.getJarEntry("closure_idx");
    JarEntry codepoints = jarFile.getJarEntry("codepoints");
    JarEntry gids = jarFile.getJarEntry("gids");
    JarEntry glyph_data = jarFile.getJarEntry("glyph_data");
    JarEntry glyph_table = jarFile.getJarEntry("glyph_table");
    jarFile.close();
  }
}

package com.github.googlei18n.tachyfont;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class TachyFontServlet extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    String jarFilename = "fonts/noto/sans/NotoSansJP-Thin_subset_smp.TachyFont.jar";
    JarFile jarFile = new JarFile("WEB-INF/" + jarFilename);
    resp.getWriter().println("Jar file: " + jarFilename);
    Enumeration<JarEntry> enumEntries = jarFile.entries();
    resp.getWriter().println("jar file entries:");
    while (enumEntries.hasMoreElements()) {
      JarEntry jarEntry = enumEntries.nextElement();
      resp.getWriter().println("  " + jarEntry.getName());
    }

    JarEntry base = jarFile.getJarEntry("base");
    InputStream baseStream = jarFile.getInputStream(base);
    JarEntry closure_data = jarFile.getJarEntry("closure_data");
    JarEntry closure_idx = jarFile.getJarEntry("closure_idx");
    JarEntry codepoints = jarFile.getJarEntry("codepoints");
    JarEntry gids = jarFile.getJarEntry("gids");
    JarEntry glyph_data = jarFile.getJarEntry("glyph_data");
    JarEntry glyph_table = jarFile.getJarEntry("glyph_table");
    jarFile.close();
  }
}

Access the base file in the JAR.


package com.redhat.ceylon.eclipse.core.typechecker;

import java.util.List;

import org.antlr.runtime.CommonToken;

import com.redhat.ceylon.compiler.typechecker.TypeChecker;
import com.redhat.ceylon.compiler.typechecker.analyzer.ModuleManager;
import com.redhat.ceylon.compiler.typechecker.context.PhasedUnit;
import com.redhat.ceylon.compiler.typechecker.io.VirtualFile;
import com.redhat.ceylon.compiler.typechecker.model.Package;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.CompilationUnit;

public class IdePhasedUnit extends PhasedUnit {

    private TypeChecker typeChecker;

    public IdePhasedUnit(VirtualFile unitFile, VirtualFile srcDir,
            CompilationUnit cu, Package p, ModuleManager moduleManager,
            TypeChecker typeChecker, List<CommonToken> tokenStream) {
        super(unitFile, srcDir, cu, p, moduleManager, typeChecker.getContext(), tokenStream);
        this.typeChecker = typeChecker;
    }

    public IdePhasedUnit(PhasedUnit other) {
        super(other);
        if (other instanceof IdePhasedUnit) {
            typeChecker = ((IdePhasedUnit) other).typeChecker;
        }
    }

    public TypeChecker getTypeChecker() {
        return typeChecker;
    }
}

package com.redhat.ceylon.eclipse.core.typechecker;

import java.util.List;

import org.antlr.runtime.CommonToken;

import com.redhat.ceylon.compiler.typechecker.TypeChecker;
import com.redhat.ceylon.compiler.typechecker.analyzer.ModuleManager;
import com.redhat.ceylon.compiler.typechecker.context.PhasedUnit;
import com.redhat.ceylon.compiler.typechecker.io.VirtualFile;
import com.redhat.ceylon.compiler.typechecker.model.Package;
import com.redhat.ceylon.compiler.typechecker.model.Unit;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.CompilationUnit;

public abstract class IdePhasedUnit extends PhasedUnit {

    private TypeChecker typeChecker;

    public IdePhasedUnit(VirtualFile unitFile, VirtualFile srcDir,
            CompilationUnit cu, Package p, ModuleManager moduleManager,
            TypeChecker typeChecker, List<CommonToken> tokenStream) {
        super(unitFile, srcDir, cu, p, moduleManager, typeChecker.getContext(), tokenStream);
        this.typeChecker = typeChecker;
    }

    public IdePhasedUnit(PhasedUnit other) {
        super(other);
        if (other instanceof IdePhasedUnit) {
            typeChecker = ((IdePhasedUnit) other).typeChecker;
        }
    }

    public TypeChecker getTypeChecker() {
        return typeChecker;
    }

    public abstract Unit createUnit();
}

Make it abstract and redefine createUnit() as abstract


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.apache.gshell.testsuite;

import org.apache.gshell.registry.CommandRegistrar;
import org.apache.maven.shell.ShellBuilder;

/**
 * Builds {@link org.apache.gshell.Shell} instances.
 *
 * @author Jason Dillon
 */
public class TestShellBuilder
    extends ShellBuilder
{
    protected void registerCommand(final String name, final String type) throws Exception {
        CommandRegistrar registrar = getContainer().lookup(CommandRegistrar.class);
        registrar.registerCommand(name, type);
    }
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.apache.gshell.testsuite;

import org.apache.gshell.registry.CommandRegistrar;
import org.apache.gshell.Shell;
import org.apache.maven.shell.ShellBuilder;

/**
 * Builds {@link org.apache.gshell.Shell} instances.
 *
 * @author Jason Dillon
 */
public class TestShellBuilder
    extends ShellBuilder
{
    protected void registerCommand(final String name, final String type) throws Exception {
        CommandRegistrar registrar = getContainer().lookup(CommandRegistrar.class);
        registrar.registerCommand(name, type);
    }

    @Override
    public Shell create() throws Exception {
        setRegisterCommands(false);
        return super.create();
    }
}

Speed up tests, only register what is required


package dk.statsbiblioteket.doms.transformers.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/** Configuration based on property file. */
public class PropertyBasedConfig implements Config {

    /** Property specifying the directory where output files will be stored. */
    public static final String OUTPUT_DIRECTORY_PROPERTY
            = "dk.statsbiblioteket.doms.transformers.outputdirectory";

    /** Properties containing configuration. */
    protected final Properties properties;

    /** Initialise based on system properties. */
    public PropertyBasedConfig() {
        properties = new Properties(System.getProperties());
    }

    /**
     * Read configuration from property file. Backed by system properties.
     *
     * @param configfile File with properties.
     * @throws IOException If file can not be read.
     */
    public PropertyBasedConfig(File configfile) throws IOException {
        this();
        properties.load(new FileInputStream(configfile));
    }

    public String getProperty(String property) {
        return properties.getProperty(property);
    }

    public String getProperty(String property, String defaultValue) {
        return properties.getProperty(property, defaultValue);
    }

    @Override
    public String getOutputDirectory() {
        return properties.getProperty(OUTPUT_DIRECTORY_PROPERTY, "output");
    }
}

package dk.statsbiblioteket.doms.transformers.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/** Configuration based on property file. */
public class PropertyBasedConfig implements Config {

    /** Property specifying the directory where output files will be stored. */
    public static final String OUTPUT_DIRECTORY_PROPERTY
            = "dk.statsbiblioteket.doms.transformers.outputdirectory";

    /** Properties containing configuration. */
    protected final Properties properties;

    /** Initialise based on system properties. */
    public PropertyBasedConfig() {
        properties = new Properties(System.getProperties());
    }

    /**
     * Read configuration from property file. Backed by system properties.
     *
     * @param configfile File with properties.
     * @throws IOException If file can not be read.
     */
    public PropertyBasedConfig(File configfile) throws IOException {
        this();
        properties.load(new FileInputStream(configfile));
    }

    @Override
    public String getOutputDirectory() {
        return properties.getProperty(OUTPUT_DIRECTORY_PROPERTY, "output");
    }
}

Revert "Persuade PropertyBaseConfig to output arbitrary properties."


package uk.ac.ebi.quickgo.annotation.download.converter.helpers;

import uk.ac.ebi.quickgo.annotation.model.Annotation;

import java.util.List;
import java.util.stream.Collectors;

/**
 * A home for the logic to format ConnectedXRefs into Strings.
 *
 * @author Tony Wardell
 * Date: 09/04/2018
 * Time: 13:06
 * Created with IntelliJ IDEA.
 */
public class ConnectedXRefs {
    private static final String PIPE = "|";
    private static final String COMMA = ",";

    private ConnectedXRefs() {}

    public static String asString(List<Annotation.ConnectedXRefs<Annotation.SimpleXRef>> connectedXRefs) {
        if (connectedXRefs == null || connectedXRefs.isEmpty()) {
            return "";
        }
        return connectedXRefs.stream()
                .map(ConnectedXRefs::simpleRefAndToString)
                .collect(Collectors.joining(PIPE));
    }

    private static String simpleRefAndToString(Annotation.ConnectedXRefs<Annotation.SimpleXRef> itemList) {
        return itemList.getConnectedXrefs()
                .stream()
                .map(Annotation.SimpleXRef::asXref)
                .collect(Collectors.joining(COMMA));
    }

}

package uk.ac.ebi.quickgo.annotation.download.converter.helpers;

import uk.ac.ebi.quickgo.annotation.model.Annotation;

import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * A home for the logic to format ConnectedXRefs into Strings.
 *
 * @author Tony Wardell
 * Date: 09/04/2018
 * Time: 13:06
 * Created with IntelliJ IDEA.
 */
public class ConnectedXRefs {
    private static final String PIPE = "|";
    private static final String COMMA = ",";

    private ConnectedXRefs() {}

    public static String asString(List<Annotation.ConnectedXRefs<Annotation.SimpleXRef>> connectedXRefs) {
        Objects.requireNonNull(connectedXRefs);
        return connectedXRefs.stream()
                .map(ConnectedXRefs::simpleRefAndToString)
                .collect(Collectors.joining(PIPE));
    }

    private static String simpleRefAndToString(Annotation.ConnectedXRefs<Annotation.SimpleXRef> itemList) {
        return itemList.getConnectedXrefs()
                .stream()
                .map(Annotation.SimpleXRef::asXref)
                .collect(Collectors.joining(COMMA));
    }

}

Change null check to throw NPE.


/*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  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
 */

package org.opendaylight.controller.concepts.transform;

public interface Acceptor<I> {

    /**
     *
     * @param input
     * @return true if input is accepted.
     */
    boolean isAcceptable(I input);
}

/*
 * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others.  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
 */

package org.opendaylight.controller.concepts.transform;

public interface Acceptor<I> {

    /**
     *
     * @param input
     * @return true if input is accepted.
     */
    boolean isAcceptable(I input);
}

Fix license header violations in concepts


/*
 * Copyright (C) 2004 Jive Software. 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
 *
 * 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.jivesoftware.database;

/**
 * Simple class for tracking profiling stats for individual SQL queries.
 *
 * @author Jive Software
 */
public class ProfiledConnectionEntry {
    /**
     * The SQL query.
     */
    public String sql;

    /**
     * Number of times the query has been executed.
     */
    public int count;

    /**
     * The total time spent executing the query (in milliseconds).
     */
    public int totalTime;

    public ProfiledConnectionEntry(String sql) {
        this.sql = sql;
        count = 0;
        totalTime = 0;
    }
}

/*
 * Copyright (C) 2004 Jive Software. 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
 *
 * 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.jivesoftware.database;

/**
 * Simple class for tracking profiling stats for individual SQL queries.
 *
 * @author Jive Software
 */
public class ProfiledConnectionEntry {
    /**
     * The SQL query.
     */
    public String sql;

    /**
     * Number of times the query has been executed.
     */
    public int count;

    /**
     * The total time spent executing the query (in milliseconds).
     */
    public long totalTime;

    public ProfiledConnectionEntry(String sql) {
        this.sql = sql;
        count = 0;
        totalTime = 0;
    }
}

Change to wider type to prevent information loss


package org.opennms.netmgt.dao.support;

import java.io.IOException;

import org.opennms.netmgt.dao.ResourceDao;
import org.opennms.netmgt.dao.support.DefaultResourceDao;
import org.opennms.netmgt.dao.support.ResponseTimeResourceType;

import junit.framework.TestCase;

public class ResponseTimeResourceTypeTest extends TestCase {
    public void testGetResourcesUsingDao() throws IOException {
        ResourceDao resourceDao = new DefaultResourceDao();

        ResponseTimeResourceType r = new ResponseTimeResourceType(resourceDao, null);

        r.getResourcesForNode(1);
    }
}

package org.opennms.netmgt.dao.support;

import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import java.io.IOException;

import org.opennms.netmgt.dao.NodeDao;
import org.opennms.netmgt.dao.ResourceDao;
import org.opennms.netmgt.dao.support.DefaultResourceDao;
import org.opennms.netmgt.dao.support.ResponseTimeResourceType;
import org.opennms.netmgt.model.OnmsNode;

import junit.framework.TestCase;

public class ResponseTimeResourceTypeTest extends TestCase {
    public void testGetResourcesUsingDao() throws IOException {
        ResourceDao resourceDao = new DefaultResourceDao();
        NodeDao nodeDao = createMock(NodeDao.class);

        expect(nodeDao.get(1)).andReturn(new OnmsNode());

        ResponseTimeResourceType r = new ResponseTimeResourceType(resourceDao, nodeDao);

        replay(nodeDao);
        r.getResourcesForNode(1);
        verify(nodeDao);
    }
}

Fix failing test by mocking up NodeDao


/*
 * Copyright 2020 Crown Copyright
 *
 * 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 stroom.event.logging.rs.impl;

import stroom.rs.logging.impl.RequestInfo;

import javax.annotation.Nullable;

public class MockRequestEventLog implements RequestEventLog {
    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity) {

    }

    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity, final Throwable error) {

    }
}

/*
 * Copyright 2020 Crown Copyright
 *
 * 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 stroom.event.logging.rs.impl;

import javax.annotation.Nullable;

public class MockRequestEventLog implements RequestEventLog {
    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity) {

    }

    @Override
    public void log(final RequestInfo info, @Nullable final Object responseEntity, final Throwable error) {

    }
}

Fix problem introduced during recent refactor


package com.infinityraider.agricraft.api.v1.client;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

/**
 * Enum representing the different types AgriCraft plants / weeds are rendered
 */
@OnlyIn(Dist.CLIENT)
public enum AgriPlantRenderType {
    /** Renders in a hashtag pattern (#); 4 faces parallel with the block faces, similar to Vanilla wheat */
    HASH,

    /** Renders in a cross pattern (x); 2 faces along the diagonals, similar to Vanilla flowers */
    CROSS,

    /** Renders in a plus pattern (+); similar to cross, but instead 4 crosses at each crop stick */
    PLUS,

    /** Renders in a rhombus pattern (◇); 4 faces spanning between the centers of the block faces, only used for weeds */
    RHOMBUS
}

package com.infinityraider.agricraft.api.v1.client;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.IExtensibleEnum;

/**
 * Enum representing the different types AgriCraft plants / weeds are rendered
 */
@OnlyIn(Dist.CLIENT)
public enum AgriPlantRenderType implements IExtensibleEnum {
    /** Renders in a hashtag pattern (#); 4 faces parallel with the block faces, similar to Vanilla wheat */
    HASH,

    /** Renders in a cross pattern (x); 2 faces along the diagonals, similar to Vanilla flowers */
    CROSS,

    /** Renders in a plus pattern (+); similar to cross, but instead 4 crosses at each crop stick */
    PLUS,

    /** Renders in a rhombus pattern (◇); 4 faces spanning between the centers of the block faces, only used for weeds */
    RHOMBUS;

    @SuppressWarnings("unused")
    public static AgriPlantRenderType create(String name) {
        throw new IllegalStateException("Enum not extended");
    }
}

Make Render Type enum extensible


package org.dynamicfinder.jpa.handler;

/**
 * @author xsalefter (xsalefter[at]gmail.com)
 */
public class LikeWithPostfixRestrictionHandler extends LikeComparatorRestrictionHandler {

	private static final String PREFIX = "'%',";
	private static final String POSTFIX = "";

	public LikeWithPostfixRestrictionHandler() {
		super(PREFIX, POSTFIX);
	}

}

package org.dynamicfinder.jpa.handler;

/**
 * @author xsalefter (xsalefter[at]gmail.com)
 */
public class LikeWithPostfixRestrictionHandler extends LikeComparatorRestrictionHandler {

	private static final String PREFIX = "'%', ";
	private static final String POSTFIX = "";

	public LikeWithPostfixRestrictionHandler() {
		super(PREFIX, POSTFIX);
	}

}

Fix generated string format. (cosmetic)


/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * 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.facebook.litho.editor.instances;

import com.facebook.litho.editor.Editor;
import com.facebook.litho.editor.model.EditorBool;
import com.facebook.litho.editor.model.EditorValue;
import java.lang.reflect.Field;

public class BoolEditorInstance implements Editor {

  @Override
  public EditorValue read(Field f, Object node) {
    return EditorValue.bool(EditorUtils.<Boolean>getNodeUNSAFE(f, node));
  }

  @Override
  public boolean write(final Field f, final Object node, final EditorValue values) {
    values.when(
        new EditorValue.DefaultEditorVisitor() {
          @Override
          public Void isBool(EditorBool bool) {
            EditorUtils.setNodeUNSAFE(f, node, bool.value);
            return null;
          }
        });
    return true;
  }
}

/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * 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.facebook.litho.editor.instances;

import com.facebook.litho.editor.Editor;
import com.facebook.litho.editor.model.EditorBool;
import com.facebook.litho.editor.model.EditorValue;
import java.lang.reflect.Field;

public class BoolEditorInstance implements Editor {

  @Override
  public EditorValue read(final Field f, final Object node) {
    // If you use Boolean here it causes an exception when attempting to do implicit conversion to
    // boolean
    final Object b = EditorUtils.<Object>getNodeUNSAFE(f, node);
    return b == null ? EditorValue.string("null") : EditorValue.bool((Boolean) b);
  }

  @Override
  public boolean write(final Field f, final Object node, final EditorValue values) {
    values.when(
        new EditorValue.DefaultEditorVisitor() {
          @Override
          public Void isBool(final EditorBool bool) {
            EditorUtils.setNodeUNSAFE(f, node, bool.value);
            return null;
          }
        });
    return true;
  }
}

Add support for nullable Booleans


package com.reactnativenavigation.params.parsers;

import android.os.Bundle;

import com.reactnativenavigation.params.ActivityParams;
import com.reactnativenavigation.params.AppStyle;
import com.reactnativenavigation.params.SideMenuParams;
import com.reactnativenavigation.views.SideMenu;

public class ActivityParamsParser extends Parser {
    public static ActivityParams parse(Bundle params) {
        ActivityParams result = new ActivityParams();

        AppStyle.setAppStyle(params);

        if (hasKey(params, "screen")) {
            result.type = ActivityParams.Type.SingleScreen;
            result.screenParams = ScreenParamsParser.parse(params.getBundle("screen"));
        }

        if (hasKey(params, "tabs")) {
            result.type = ActivityParams.Type.TabBased;
            result.tabParams = new ScreenParamsParser().parseTabs(params.getBundle("tabs"));
        }

        if (hasKey(params, "sideMenu")) {
            SideMenuParams[] sideMenus = SideMenuParamsParser.parse(params.getBundle("sideMenu"));
            result.leftSideMenuParams = sideMenus[SideMenu.Side.Left.ordinal()];
            result.rightSideMenuParams = sideMenus[SideMenu.Side.Right.ordinal()];
        }

        result.animateShow = params.getBoolean("animateShow", true);

        return result;
    }
}

package com.reactnativenavigation.params.parsers;

import android.os.Bundle;

import com.reactnativenavigation.params.ActivityParams;
import com.reactnativenavigation.params.AppStyle;
import com.reactnativenavigation.params.SideMenuParams;
import com.reactnativenavigation.views.SideMenu;

public class ActivityParamsParser extends Parser {
    public static ActivityParams parse(Bundle params) {
        ActivityParams result = new ActivityParams();

        AppStyle.setAppStyle(params);

        if (hasKey(params, "screen")) {
            result.type = ActivityParams.Type.SingleScreen;
            result.screenParams = ScreenParamsParser.parse(params.getBundle("screen"));
        }

        if (hasKey(params, "tabs")) {
            result.type = ActivityParams.Type.TabBased;
            result.tabParams = new ScreenParamsParser().parseTabs(params.getBundle("tabs"));
            if (result.tabParams.size() == 0) {
                throw new RuntimeException("Tried to start tab based app with zero tabs");
            }
        }

        if (hasKey(params, "sideMenu")) {
            SideMenuParams[] sideMenus = SideMenuParamsParser.parse(params.getBundle("sideMenu"));
            result.leftSideMenuParams = sideMenus[SideMenu.Side.Left.ordinal()];
            result.rightSideMenuParams = sideMenus[SideMenu.Side.Right.ordinal()];
        }

        result.animateShow = params.getBoolean("animateShow", true);

        return result;
    }
}

Throw exception when calling startTabBasedApp with zero tabs


package com.infinityraider.infinitylib.item;

import com.infinityraider.infinitylib.render.item.IItemRenderingHandler;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public interface ICustomRenderedItem<I extends Item> {
    /**
     * Gets called to create the IBlockRenderingHandler instance to render this block with
     * @return a new IItemRenderingHandler object for this block
     */
    @SideOnly(Side.CLIENT)
    IItemRenderingHandler<I> getRenderer();

    /**
     * Gets an array of ResourceLocations used for the model of this block, all block states for this block will use this as key in the model registry
     * @return a unique ModelResourceLocation for this block
     */
    @SideOnly(Side.CLIENT)
    ModelResourceLocation getItemModelResourceLocation();
}

package com.infinityraider.infinitylib.item;

import com.infinityraider.infinitylib.render.item.IItemRenderingHandler;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.List;

public interface ICustomRenderedItem<I extends Item> {
    /**
     * Gets called to create the IBlockRenderingHandler instance to render this block with
     * @return a new IItemRenderingHandler object for this block
     */
    @SideOnly(Side.CLIENT)
    IItemRenderingHandler<I> getRenderer();

    /**
     * Gets a list of all textures necessary to render this item,
     * returned textures will be stitched to the atlas
     * @return list of textures
     */
    @SideOnly(Side.CLIENT)
    List<ResourceLocation> getTextures();

    /**
     * Gets an array of ResourceLocations used for the model of this block, all block states for this block will use this as key in the model registry
     * @return a unique ModelResourceLocation for this block
     */
    @SideOnly(Side.CLIENT)
    ModelResourceLocation getItemModelResourceLocation();
}

Add get textures method for items


package com.hubspot.jinjava.util;

import com.hubspot.jinjava.interpret.OutputTooBigException;
import java.io.Serializable;
import java.util.stream.IntStream;

public class LengthLimitingStringBuilder implements Serializable, CharSequence {
  private static final long serialVersionUID = -1891922886257965755L;

  private final StringBuilder builder;
  private long length = 0;
  private final long maxLength;

  public LengthLimitingStringBuilder(long maxLength) {
    builder = new StringBuilder();
    this.maxLength = maxLength;
  }

  @Override
  public int length() {
    return builder.length();
  }

  @Override
  public char charAt(int index) {
    return builder.charAt(index);
  }

  @Override
  public CharSequence subSequence(int start, int end) {
    return builder.subSequence(start, end);
  }

  @Override
  public String toString() {
    return builder.toString();
  }

  @Override
  public IntStream chars() {
    return builder.chars();
  }

  @Override
  public IntStream codePoints() {
    return builder.codePoints();
  }

  public void append(Object obj) {
    append(String.valueOf(obj));
  }

  public void append(String str) {
    length += str.length();
    if (maxLength > 0 && length > maxLength) {
      throw new OutputTooBigException(maxLength, length);
    }
    builder.append(str);
  }
}

package com.hubspot.jinjava.util;

import com.hubspot.jinjava.interpret.OutputTooBigException;
import java.io.Serializable;
import java.util.stream.IntStream;

public class LengthLimitingStringBuilder implements Serializable, CharSequence {
  private static final long serialVersionUID = -1891922886257965755L;

  private final StringBuilder builder;
  private long length = 0;
  private final long maxLength;

  public LengthLimitingStringBuilder(long maxLength) {
    builder = new StringBuilder();
    this.maxLength = maxLength;
  }

  @Override
  public int length() {
    return builder.length();
  }

  @Override
  public char charAt(int index) {
    return builder.charAt(index);
  }

  @Override
  public CharSequence subSequence(int start, int end) {
    return builder.subSequence(start, end);
  }

  @Override
  public String toString() {
    return builder.toString();
  }

  @Override
  public IntStream chars() {
    return builder.chars();
  }

  @Override
  public IntStream codePoints() {
    return builder.codePoints();
  }

  public void append(Object obj) {
    append(String.valueOf(obj));
  }

  public void append(String str) {
    if (str == null) {
      return;
    }
    length += str.length();
    if (maxLength > 0 && length > maxLength) {
      throw new OutputTooBigException(maxLength, length);
    }
    builder.append(str);
  }
}

Check for null value before appending


package ua.uagames.borsch.v002;

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

public class MainActivity extends AppCompatActivity {

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

package ua.uagames.borsch.v002;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.firebase.analytics.FirebaseAnalytics;

public class MainActivity extends AppCompatActivity {
    private WebView viewer;
    private FirebaseAnalytics analytics;
    private Bundle bundle;

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

        analytics = FirebaseAnalytics.getInstance(this);
        bundle = new Bundle();

        viewer = (WebView) findViewById(R.id.viewer);
        viewer.getSettings().setJavaScriptEnabled(true);
        viewer.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return false;
            }
        });

        viewer.loadUrl("https://drive.google.com/file/d/0B3qWNFQol8lILVlzQlJ3V3VHTTg/view?usp=sharing");

        bundle.putString("app_name", "Borsch v002.");
        bundle.putString("app_event", "Create app and load content.");
        analytics.logEvent("app_statistics", bundle);
    }
}

Change project Borschv002. Add app functional with firebase statistics.


/* 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.flowable.engine.test.bpmn.event.variable;

import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.impl.el.ExpressionManager;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.impl.util.CommandContextUtil;

public class SetVariableExpression {

    public void setVariable(String variable, Object value, DelegateExecution execution) {
        ExpressionManager expressionManager = CommandContextUtil.getProcessEngineConfiguration().getExpressionManager();
        Expression expression = expressionManager.createExpression("${" + variable + "}");
        expression.setValue(value, execution);
    }
}

Add missing license header block


/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.uiapp;

import androidx.annotation.VisibleForTesting;
import com.facebook.jni.HybridData;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.soloader.SoLoader;
import java.util.List;

/** This class is responsible for creating all the TurboModules for the RNTester app. */
public class RNTesterTurboModuleManagerDelegate extends ReactPackageTurboModuleManagerDelegate {
  private static volatile boolean sIsSoLibraryLoaded;

  protected native HybridData initHybrid();

  @VisibleForTesting
  native boolean canCreateTurboModule(String moduleName);

  private RNTesterTurboModuleManagerDelegate(
      ReactApplicationContext context, List<ReactPackage> packages) {
    super(context, packages);
  }

  public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
    protected RNTesterTurboModuleManagerDelegate build(
        ReactApplicationContext context, List<ReactPackage> packages) {
      return new RNTesterTurboModuleManagerDelegate(context, packages);
    }
  }

  @Override
  protected void maybeLoadOtherSoLibraries() {
    maybeLoadSoLibraries();
  }

  // Prevents issues with initializer interruptions.
  private static synchronized void maybeLoadSoLibraries() {
    if (!sIsSoLibraryLoaded) {
      SoLoader.loadLibrary("rntester_appmodules");
      sIsSoLibraryLoaded = true;
    }
  }
}

/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.uiapp;

import androidx.annotation.VisibleForTesting;
import com.facebook.jni.HybridData;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.soloader.SoLoader;
import java.util.List;

/** This class is responsible for creating all the TurboModules for the RNTester app. */
public class RNTesterTurboModuleManagerDelegate extends ReactPackageTurboModuleManagerDelegate {
  private static volatile boolean sIsSoLibraryLoaded;

  protected native HybridData initHybrid();

  @VisibleForTesting
  native boolean canCreateTurboModule(String moduleName);

  private RNTesterTurboModuleManagerDelegate(
      ReactApplicationContext context, List<ReactPackage> packages) {
    super(context, packages);
  }

  public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
    protected RNTesterTurboModuleManagerDelegate build(
        ReactApplicationContext context, List<ReactPackage> packages) {
      return new RNTesterTurboModuleManagerDelegate(context, packages);
    }
  }

  @Override
  protected synchronized void maybeLoadOtherSoLibraries() {
    // Prevents issues with initializer interruptions.
    if (!sIsSoLibraryLoaded) {
      SoLoader.loadLibrary("rntester_appmodules");
      sIsSoLibraryLoaded = true;
    }
  }
}

Make So loading inside generated TMM delegates less confusing


package com.redhat.che.keycloak.server;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class KeycloakAuthenticationFilter extends org.keycloak.adapters.servlet.KeycloakOIDCFilter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        String auth = request.getHeader("Authorization");
        if(auth == null ){
            System.out.println("No auth header for " + request.getRequestURI());
        }
        if(auth != null && auth.equals("Internal")){
            chain.doFilter(req, res);
        }else
        if (request.getRequestURI().endsWith("/ws") || request.getRequestURI().endsWith("/eventbus")
                || request.getScheme().equals("ws") || req.getScheme().equals("wss")) {
            System.out.println("Skipping " + request.getRequestURI());
            chain.doFilter(req, res);
        } else {
            super.doFilter(req, res, chain);
            System.out.println(request.getRequestURL() + " status : " + ((HttpServletResponse) res).getStatus());
        }
    }

}

package com.redhat.che.keycloak.server;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class KeycloakAuthenticationFilter extends org.keycloak.adapters.servlet.KeycloakOIDCFilter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        String auth = request.getHeader("Authorization");
        if(auth == null ){
            System.out.println("No auth header for " + request.getRequestURI());
        }
        if(auth != null && auth.equals("Internal")){
            chain.doFilter(req, res);
        } else if (request.getRequestURI().endsWith("/ws") || request.getRequestURI().endsWith("/eventbus")
                   || request.getScheme().equals("ws") || req.getScheme().equals("wss") || request.getRequestURI().contains("/websocket/")) {
            System.out.println("Skipping " + request.getRequestURI());
            chain.doFilter(req, res);
        } else {
            super.doFilter(req, res, chain);
            System.out.println(request.getRequestURL() + " status : " + ((HttpServletResponse) res).getStatus());
        }
    }

}

Fix keycloak auth filter not excluded all websocket request


package edu.berkeley.eecs.cfc_tracker.test.location;

import android.content.Intent;
import android.util.Log;

/**
 * Created by shankari on 1/18/15.
 */
public class MockLocationBroadcastChecker extends BroadcastChecker {
    private static final String TAG = "MockLocationBroadcastChecker";
    private int code1;
    private int code2;

    public MockLocationBroadcastChecker(String broadcastAction, int code1, int code2) {
        super(broadcastAction);
        this.code1 = code1;
        this.code2 = code2;
        Log.d(TAG, "Creation done with "+broadcastAction+", "+code1+", "+code2);
    }

    public boolean isMatchingIntent(Intent intent) {
        if (super.isMatchingIntent(intent)) {
            int iCode1 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE1, 0);
            int iCode2 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE2, 0);
            Log.d(TAG, "intent string matches, checking extra codes from intent "+
                iCode1+", "+iCode2+" against stored "+code1+", "+code2);

            if (iCode1 == code1 &&
                    iCode2 == code2) {
                return true;
            }
        }
        return false;
    }
}

package edu.berkeley.eecs.cfc_tracker.test.location;

import android.content.Intent;
import android.util.Log;

/**
 * Created by shankari on 1/18/15.
 */
public class MockLocationBroadcastChecker extends BroadcastChecker {
    private static final String TAG = "MockLocationBrdcstChker";
    private int code1;
    private int code2;

    public MockLocationBroadcastChecker(String broadcastAction, int code1, int code2) {
        super(broadcastAction);
        this.code1 = code1;
        this.code2 = code2;
        Log.d(TAG, "Creation done with "+broadcastAction+", "+code1+", "+code2);
    }

    public boolean isMatchingIntent(Intent intent) {
        if (super.isMatchingIntent(intent)) {
            int iCode1 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE1, 0);
            int iCode2 = intent.getIntExtra(LocationUtils.KEY_EXTRA_CODE2, 0);
            Log.d(TAG, "intent string matches, checking extra codes from intent "+
                iCode1+", "+iCode2+" against stored "+code1+", "+code2);

            if (iCode1 == code1 &&
                    iCode2 == code2) {
                return true;
            }
        }
        return false;
    }
}

Change the tag to fit the size requirements of the log class


/*
 * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.xdi.model.custom.script.type.client;

import java.util.Map;

import org.xdi.model.SimpleCustomProperty;
import org.xdi.model.custom.script.type.BaseExternalType;

/**
 * Base interface for external custom client registration python script
 *
 * @author Yuriy Movchan Date: 11/11/2014
 */
public interface ClientRegistrationType extends BaseExternalType {

    boolean updateClient(Object registerRequest, Object client, Map<String, SimpleCustomProperty> configurationAttributes);

}

/*
 * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.xdi.model.custom.script.type.client;

import java.util.Map;

import org.xdi.model.SimpleCustomProperty;
import org.xdi.model.custom.script.type.BaseExternalType;

/**
 * Base interface for external custom client registration python script
 *
 * @author Yuriy Movchan Date: 11/11/2014
 */
public interface ClientRegistrationType extends BaseExternalType {

    public boolean createClient(Object registerRequest, Object client, Map<String, SimpleCustomProperty> configurationAttributes);

    public boolean updateClient(Object registerRequest, Object client, Map<String, SimpleCustomProperty> configurationAttributes);

}

Add create client method to client registration script


/*
 * Copyright © 2017 the original authors (http://cereebro.io)
 *
 * 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.cereebro.sample.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import io.cereebro.server.EnableCereebroServer;

@SpringBootApplication
@EnableCereebroServer
public class CereebroSampleServerEurekaClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(CereebroSampleServerEurekaClientApplication.class, args);
    }

}

/*
 * Copyright © 2017 the original authors (http://cereebro.io)
 *
 * 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.cereebro.sample.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import io.cereebro.server.EnableCereebroServer;

@SpringBootApplication
@EnableCereebroServer
@EnableDiscoveryClient
public class CereebroSampleServerEurekaClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(CereebroSampleServerEurekaClientApplication.class, args);
    }

}

Add missing @EnableDiscoveryClient in standalone server sample


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.apache.geronimo.gshell.event;

/**
 * Adapter for typed {@link Event} processing.
 *
 * @version $Rev$ $Date$
 */
public abstract class EventAdapter<T extends Event>
    implements EventListener
{
    @SuppressWarnings({"unchecked"})
    public void onEvent(final Event event) throws Exception {
        T targetEvent = null;

        // HACK: Can't check the type from T, so just handle the CCE, might not be very efficent though :-(
        try {
            targetEvent = (T)event;
        }
        catch (ClassCastException ignore) {}

        if (targetEvent != null) {
            handleEvent(targetEvent);
        }
    }

    protected abstract void handleEvent(T event) throws Exception;
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.apache.geronimo.gshell.event;

/**
 * Adapter for typed {@link Event} processing.
 *
 * @version $Rev$ $Date$
 */
public abstract class EventAdapter<T extends Event>
    implements EventListener
{
    @SuppressWarnings({"unchecked"})
    public void onEvent(final Event event) throws Exception {
        assert event != null;

        // HACK: Can't check the type from T, so just handle the CCE, might not be very efficent though :-(
        try {
            handleEvent((T)event);
        }
        catch (ClassCastException ignore) {}
    }

    protected abstract void handleEvent(T event) throws Exception;
}

Revert back to first hack attempt, maybe need to implement a better event subscription model