package alien4cloud.it.maintenance;

import static alien4cloud.it.Context.getRestClientInstance;

import org.alien4cloud.server.MaintenanceUpdateDTO;

import alien4cloud.it.Context;
import cucumber.api.java.en.When;

/**
 * Steps for maintenance mode cucumber rest it.
 */
public class MaintenanceStepsDefinition {

    @When("^I enable maintenance mode$")
    public void enable() throws Throwable {
        Context.getInstance().registerRestResponse(getRestClientInstance().post("/rest/v1/maintenance"));
    }

    @When("^I disable maintenance mode$")
    public void disable() throws Throwable {
        Context.getInstance().registerRestResponse(getRestClientInstance().delete("/rest/v1/maintenance"));
    }

    @When("^I get maintenance state$")
    public void getState() throws Throwable {
        Context.getInstance().registerRestResponse(getRestClientInstance().get("/rest/v1/maintenance"));
    }

    @When("^I update maintenance state, message: \"([^\"]*)\" percent: (\\d+)$")
    public void updateState(String message, Float percent) throws Throwable {
        MaintenanceUpdateDTO updateDTO = new MaintenanceUpdateDTO(message, percent);
        Context.getInstance()
                .registerRestResponse(getRestClientInstance().putJSon("/rest/v1/maintenance", Context.getJsonMapper().writeValueAsString(updateDTO)));
    }
}

package alien4cloud.it.maintenance;

import static alien4cloud.it.Context.getRestClientInstance;

import org.alien4cloud.server.MaintenanceUpdateDTO;

import alien4cloud.it.Context;
import cucumber.api.java.en.When;

/**
 * Steps for maintenance mode cucumber rest it.
 */
public class MaintenanceStepsDefinition {

    @When("^I enable maintenance mode$")
    public void enable() throws Throwable {
        Context.getInstance().registerRestResponse(getRestClientInstance().post("/rest/v1/maintenance"));
    }

    @When("^I disable maintenance mode$")
    public void disable() throws Throwable {
        Context.getInstance().registerRestResponse(getRestClientInstance().delete("/rest/v1/maintenance"));
    }

    @When("^I get maintenance state$")
    public void getState() throws Throwable {
        Context.getInstance().registerRestResponse(getRestClientInstance().get("/rest/v1/maintenance"));
    }

    @When("^I update maintenance state, message: \"([^\"]*)\" percent: (\\d+)$")
    public void updateState(String message, Integer percent) throws Throwable {
        MaintenanceUpdateDTO updateDTO = new MaintenanceUpdateDTO(message, percent);
        Context.getInstance()
                .registerRestResponse(getRestClientInstance().putJSon("/rest/v1/maintenance", Context.getJsonMapper().writeValueAsString(updateDTO)));
    }
}

Fix compilation error in test.

Fix compilation error in test.


/*
 * Copyright (C) 2015 hops.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.hops.metadata.hdfs.dal;

import io.hops.exception.StorageException;
import io.hops.metadata.common.EntityDataAccess;

import java.util.Collection;

public interface SafeBlocksDataAccess extends EntityDataAccess {

  void insert(Collection<Long> safeBlocks) throws StorageException;

  void remove(Long safeBlock) throws StorageException;

  int countAll() throws StorageException;

  void removeAll() throws StorageException;
}

/*
 * Copyright (C) 2015 hops.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.hops.metadata.hdfs.dal;

import io.hops.exception.StorageException;
import io.hops.metadata.common.EntityDataAccess;

import java.util.Collection;

public interface SafeBlocksDataAccess extends EntityDataAccess {

  void insert(Collection<Long> safeBlocks) throws StorageException;

  void remove(Long safeBlock) throws StorageException;

  int countAll() throws StorageException;

  void removeAll() throws StorageException;

  boolean isSafe(Long BlockId) throws StorageException;
}

[HOPS-1360] Fix Tuple does not exist in removeSafeBlock


package me.coley.recaf.decompile;

import me.coley.recaf.workspace.Workspace;

import java.util.Map;

/**
 * Decompiler base.
 *
 * @author Matt.
 */
public abstract class Decompiler<OptionType> {
	private final Map<String, OptionType> defaultOptions = generateDefaultOptions();
	private Map<String, OptionType> options = defaultOptions;

	/**
	 * @return Map of the current options.
	 */
	public Map<String, OptionType> getOptions() {
		return options;
	}

	/**
	 * @param options
	 * 		Map of the options to use.
	 */
	public void setOptions(Map<String, OptionType> options) {
		this.options = options;
	}

	/**
	 * @return Map of the default decompiler options.
	 */
	public Map<String, OptionType> getDefaultOptions() {
		return defaultOptions;
	}

	/**
	 * @return Map of the default decompiler options.
	 */
	protected abstract Map<String, OptionType> generateDefaultOptions();

	/**
	 * @param workspace
	 * 		Workspace to pull classes from.
	 * @param name
	 * 		Name of the class to decompile.
	 *
	 * @return Decompiled text of the class.
	 */
	public abstract String decompile(Workspace workspace, String name);
}

package me.coley.recaf.decompile;

import me.coley.recaf.workspace.Workspace;

import java.util.*;

/**
 * Decompiler base.
 *
 * @author Matt.
 */
public abstract class Decompiler<OptionType> {
	private final Map<String, OptionType> defaultOptions = Collections.unmodifiableMap(generateDefaultOptions());
	private Map<String, OptionType> options = new HashMap<>(defaultOptions);

	/**
	 * @return Map of the current options.
	 */
	public Map<String, OptionType> getOptions() {
		return options;
	}

	/**
	 * @param options
	 * 		Map of the options to use.
	 */
	public void setOptions(Map<String, OptionType> options) {
		this.options = options;
	}

	/**
	 * @return Map of the default decompiler options.
	 */
	public Map<String, OptionType> getDefaultOptions() {
		return defaultOptions;
	}

	/**
	 * @return Map of the default decompiler options.
	 */
	protected abstract Map<String, OptionType> generateDefaultOptions();

	/**
	 * @param workspace
	 * 		Workspace to pull classes from.
	 * @param name
	 * 		Name of the class to decompile.
	 *
	 * @return Decompiled text of the class.
	 */
	public abstract String decompile(Workspace workspace, String name);
}

Make default options map unmodifiable

Make default options map unmodifiable


package de.fau.osr.core.vcs.base;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by Rajab Kaoneka on 18.05.2015.
 */
public class CommitTest {

    @Test
    public void CommitConstructor_idField_Test(){
        Commit commitToTest = new Commit("new_id", null, null, null);
        assertEquals("commit id should be equal the initialization id", "new_id", commitToTest.id);
    }

    @Test
    public void CommitConstructor_messageField_Test(){
        Commit commitToTest = new Commit(null, "msg ok", null, null);
        assertEquals("message should be equal the initialization message", "msg ok", commitToTest.message);
    }
}

package de.fau.osr.core.vcs.base;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by Rajab Kaoneka on 18.05.2015.
 */
public class CommitTest {

    @Test
    public void CommitConstructor_idField_Test(){
        Commit commitToTest = new Commit("new_id", null, null, null);
        assertEquals("commit id should be equal the initialization id", "new_id", commitToTest.id);
    }

    public void CommitConstructor_CommitIdInitializedWithNoUsualChars_allTheCharsReturnedProperly(){
        String[] ids = {"   ", "$&/&$//", "09084§§§", " kl%45$$%$%", "\"\"__ __\"\"", "", null};
        for (String id : ids){
            Commit commitToTest = new Commit(id, null, null, null);
            assertEquals("commit id should be equal the initialization id", id, commitToTest.id);
        }
    }

    @Test
    public void CommitConstructor_messageField_Test(){
        Commit commitToTest = new Commit(null, "msg ok", null, null);
        assertEquals("message should be equal the initialization message", "msg ok", commitToTest.message);
    }

}

Test for commit, testing message initialization with unusual chars for id


package de.altenerding.biber.pinkie.user.bounday;

import de.altenerding.biber.pinkie.user.entity.User;

import javax.inject.Inject;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
import java.util.Optional;

@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
public class UserResource {
    @Inject
    UserService userService;

    @GET
    public Response getUsers() {
        List<User> users = userService.getUsers();
        return Response.ok(users).build();
    }

    @GET
    @Path("{id}")
    public Response getUser(@PathParam("id") long id) {
        Optional<User> user = userService.getUser(id);

        if (!user.isPresent()) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        return Response.ok(user).build();
    }

    @POST
    @Path("/login")
    public Response login(@FormParam("name") String name, @FormParam("password") String password) {
        return Response.ok().build();
    }
}

package de.altenerding.biber.pinkie.user.bounday;

import de.altenerding.biber.pinkie.user.entity.User;

import javax.inject.Inject;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
import java.util.Optional;

@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
public class UserResource {
    @Inject
    UserService userService;

    @GET
    public Response getUsers() {
        List<User> users = userService.getUsers();
        return Response.ok(users).build();
    }

    @GET
    @Path("{id}")
    public Response getUser(@PathParam("id") long id) {
        Optional<User> user = userService.getUser(id);

        if (!user.isPresent()) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        return Response.ok(user.get()).build();
    }

    @POST
    @Path("/login")
    public Response login(@FormParam("name") String name, @FormParam("password") String password) {
        return Response.ok().build();
    }
}

Return user instead of optional object

Return user instead of optional object


/*
 * 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.jmeter.protocol.jms.sampler;

import javax.jms.JMSException;
import javax.jms.Message;

/**
 * Executor for (pseudo) synchronous communication.

 * Created on: October 28, 2004
 *
 * @version $Revision$
 */
public interface QueueExecutor {
    /**
     * Sends and receives a message.
     *
     * @param request the message to send
     * @param deliveryMode the delivery mode to use
     * @param priority the priority for this message
     * @param expiration messages lifetime in ms
     * @return the received message or null
     * @throws JMSException
     *             in case of an exception from the messaging system
     */
    Message sendAndReceive(Message request,
            int deliveryMode,
            int priority,
            long expiration) throws JMSException;

}

/*
 * 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.jmeter.protocol.jms.sampler;

import javax.jms.JMSException;
import javax.jms.Message;

/**
 * Executor for (pseudo) synchronous communication.

 * Created on: October 28, 2004
 *
 */
public interface QueueExecutor {
    /**
     * Sends and receives a message.
     *
     * @param request the message to send
     * @param deliveryMode the delivery mode to use
     * @param priority the priority for this message
     * @param expiration messages lifetime in ms
     * @return the received message or null
     * @throws JMSException
     *             in case of an exception from the messaging system
     */
    Message sendAndReceive(Message request,
            int deliveryMode,
            int priority,
            long expiration) throws JMSException;

}

Remove @version that uses svn revision as it makes useless differences when comparing svn with github

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1788653 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: 8183e740a37445656dfa610e0f7d203e2d765f57


package openperipheral.addons.glasses;

import java.util.Map;

import net.minecraft.item.ItemStack;
import openperipheral.addons.api.ITerminalItem;
import openperipheral.api.helpers.ItemStackMetaProviderSimple;

import com.google.common.collect.Maps;

public class ItemTerminalMetaProvider extends ItemStackMetaProviderSimple<ITerminalItem> {

	@Override
	public String getKey() {
		return "op-terminal";
	}

	@Override
	public Object getMeta(ITerminalItem target, ItemStack stack) {
		Map<String, Object> results = Maps.newHashMap();
		final Long terminalGuid = target.getTerminalGuid(stack);
		if (terminalGuid != null) results.put("bridge-name", TerminalUtils.formatTerminalId(terminalGuid));
		return results;
	}
}

package openperipheral.addons.glasses;

import java.util.Map;

import net.minecraft.item.ItemStack;
import openperipheral.addons.api.ITerminalItem;
import openperipheral.api.helpers.ItemStackMetaProviderSimple;

import com.google.common.collect.Maps;

public class ItemTerminalMetaProvider extends ItemStackMetaProviderSimple<ITerminalItem> {

	@Override
	public String getKey() {
		return "op_terminal";
	}

	@Override
	public Object getMeta(ITerminalItem target, ItemStack stack) {
		Map<String, Object> results = Maps.newHashMap();
		final Long terminalGuid = target.getTerminalGuid(stack);
		if (terminalGuid != null) results.put("bridge_name", TerminalUtils.formatTerminalId(terminalGuid));
		return results;
	}
}

Tweak glasses meta provider names

Tweak glasses meta provider names


package com.leafriend.kspay.receiver;

import static org.hamcrest.Matchers.*;

import static org.junit.Assert.*;

import org.junit.Test;

public class DaemonTest {

    @Test
    public void testCallingShutdonwCallback() throws InterruptedException {

        // Given
        class Callback implements Runnable {

            boolean isCalled = false;

            @Override
            public void run() {
                isCalled = true;
            }

            @Override
            public String toString() {
                return "TestCallback";
            }

        }
        Daemon daemon = new Daemon(29992);
        Callback callback = new Callback();
        daemon.addShutdownCallback(callback);
        new Thread(daemon).start();

        // When
        Thread.sleep(100);
        daemon.stop();
        Thread.sleep(100);

        // Then
        assertThat("Callback is called", callback.isCalled, is(true));

    }

}

package com.leafriend.kspay.receiver;

import static org.hamcrest.Matchers.*;

import static org.junit.Assert.*;

import org.junit.Test;

public class DaemonTest {

    @Test
    public void testCallingShutdonwCallback() throws InterruptedException {

        // Given
        class Callback implements Runnable {

            boolean isCalled = false;

            @Override
            public void run() {
                isCalled = true;
            }

            @Override
            public String toString() {
                return "TestCallback";
            }

        }
        Daemon daemon = new Daemon(29992);
        Callback callback = new Callback();
        daemon.addShutdownCallback(callback);
        new Thread(daemon).start();

        // When
        Thread.sleep(200);
        daemon.stop();
        Thread.sleep(200);

        // Then
        assertThat("Callback is called", callback.isCalled, is(true));

    }

}

Increase waiting time to pass testing on console


package com.beepscore.android.sunshine;

import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

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

/**
 * A placeholder fragment containing a simple view.
 */
public class MainActivityFragment extends Fragment {

    public MainActivityFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View fragmentMainView = inflater.inflate(R.layout.fragment_main, container, false);
        //configureDateViewInView(fragmentMainView);
        return fragmentMainView;
    }

    /*
    private void configureDateViewInView(View fragmentMainView) {
        // Android TextClock would be nice, but requires SDK >= 17. So don't use it.
        // https://developer.android.com/reference/android/widget/TextClock.html

        TextView dateView = (TextView) fragmentMainView.findViewById(R.id.dateView);

        // use user's preselected settings
        DateFormat dateFormat = DateFormat.getDateInstance();

        // Get calendar with default locale and time zone. Don't assume Gregorian
        Calendar calendar = Calendar.getInstance();
        Date now = calendar.getTime();

        String formattedDate = dateFormat.format(now);
        dateView.setText(formattedDate);
    }
    */
}

package com.beepscore.android.sunshine;

import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

//import java.text.DateFormat;
import java.util.ArrayList;
//import java.util.Calendar;
//import java.util.Date;
import java.util.List;

/**
 * A placeholder fragment containing a simple view.
 */
public class MainActivityFragment extends Fragment {

    public MainActivityFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View fragmentMainView = inflater.inflate(R.layout.fragment_main, container, false);
        configureList();
        return fragmentMainView;
    }

    private void configureList() {
        List<String> list = new ArrayList<String>;

        list.add("Today - Sunny - 88/63");
        list.add("Tomorrow - Foggy - 70/46");
        list.add("Weds - Cloudy - 72/63");
        list.add("Thurs - Rainy - 64/51");
        list.add("Fri - Foggy - 70/46");
        list.add("Sat - Sunny - 76/68");
    }

}

Delete commented out configureDateViewInView. Add configureList.


package com.indeed.proctor.store;

import java.util.List;
import java.util.Objects;

/**
 * Details of a single revision
 */
public class RevisionDetails {
    private final Revision revision;
    private final List<String> modifiedTests;

    public RevisionDetails(
            final Revision revision,
            final List<String> modifiedTests
    ) {
        this.revision = revision;
        this.modifiedTests = modifiedTests;
    }

    public Revision getRevision() {
        return revision;
    }

    public List<String> getModifiedTests() {
        return modifiedTests;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final RevisionDetails that = (RevisionDetails) o;
        return Objects.equals(modifiedTests, that.modifiedTests);
    }

    @Override
    public int hashCode() {
        return Objects.hash(modifiedTests);
    }
}

package com.indeed.proctor.store;

import java.util.Objects;
import java.util.Set;

/**
 * Details of a single revision
 */
public class RevisionDetails {
    private final Revision revision;
    private final Set<String> modifiedTests;

    public RevisionDetails(
            final Revision revision,
            final Set<String> modifiedTests
    ) {
        this.revision = revision;
        this.modifiedTests = modifiedTests;
    }

    public Revision getRevision() {
        return revision;
    }

    public Set<String> getModifiedTests() {
        return modifiedTests;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final RevisionDetails that = (RevisionDetails) o;
        return Objects.equals(revision, that.revision) &&
                Objects.equals(modifiedTests, that.modifiedTests);
    }

    @Override
    public int hashCode() {
        return Objects.hash(revision, modifiedTests);
    }

    @Override
    public String toString() {
        return com.google.common.base.Objects.toStringHelper(this)
                .add("revision", revision)
                .add("modifiedTests", modifiedTests)
                .toString();
    }
}

PROC-592: Use set for modified tests in revision details


package com.yuyakaido.android.cardstackview.sample;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CardAdapter extends ArrayAdapter<String> {

    public CardAdapter(Context context) {
        super(context, 0);
    }

    @Override
    public View getView(int position, View contentView, ViewGroup parent) {
        if (contentView == null) {
            contentView = View.inflate(getContext(), R.layout.item_card_stack, null);
        }

        TextView v = (TextView) (contentView.findViewById(R.id.item_card_stack_text));
        v.setText(getItem(position));

        return contentView;
    }

}

package com.yuyakaido.android.cardstackview.sample;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CardAdapter extends ArrayAdapter<String> {

    public CardAdapter(Context context) {
        super(context, 0);
    }

    @Override
    public View getView(int position, View contentView, ViewGroup parent) {
        ViewHolder holder;

        if (contentView == null) {
            contentView = View.inflate(getContext(), R.layout.item_card_stack, null);
            holder = new ViewHolder(contentView);
            contentView.setTag(holder);
        } else {
            holder = (ViewHolder) contentView.getTag();
        }

        holder.textView.setText(getItem(position));

        return contentView;
    }

    private static class ViewHolder {
        public TextView textView;

        public ViewHolder(View view) {
            this.textView = (TextView) view.findViewById(R.id.item_card_stack_text);
        }
    }

}

Use ViewHolder pattern in sample adapter


package com.yammer.tenacity.core.properties;

import com.netflix.config.ConfigurationManager;
import com.netflix.config.DynamicConfiguration;
import com.netflix.config.FixedDelayPollingScheduler;
import com.netflix.config.PolledConfigurationSource;
import com.netflix.config.sources.URLConfigurationSource;
import com.yammer.tenacity.core.config.BreakerboxConfiguration;
import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ArchaiusPropertyRegister {
    private static class TenacityPollingScheduler extends FixedDelayPollingScheduler {
        private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPollingScheduler.class);

        public TenacityPollingScheduler(int initialDelayMillis, int delayMillis, boolean ignoreDeletesFromSource) {
            super(initialDelayMillis, delayMillis, ignoreDeletesFromSource);
        }

        @Override
        protected synchronized void initialLoad(PolledConfigurationSource source, Configuration config) {
            try {
                super.initialLoad(source, config);
            } catch (Exception err) {
                LOGGER.warn("Initial dynamic configuration load failed", err);
            }
        }
    }
    public void register(BreakerboxConfiguration breakerboxConfiguration) {
        if(breakerboxConfiguration.getUrls().isEmpty()) return;
        ConfigurationManager.install(
                new DynamicConfiguration(
                    new URLConfigurationSource(breakerboxConfiguration.getUrls().split(",")),
                    new TenacityPollingScheduler(
                            (int)breakerboxConfiguration.getInitialDelay().toMilliseconds(),
                            (int)breakerboxConfiguration.getDelay().toMilliseconds(),
                            true)));
    }
}

package com.yammer.tenacity.core.properties;

import com.netflix.config.ConfigurationManager;
import com.netflix.config.DynamicConfiguration;
import com.netflix.config.FixedDelayPollingScheduler;
import com.netflix.config.PolledConfigurationSource;
import com.netflix.config.sources.URLConfigurationSource;
import com.yammer.tenacity.core.config.BreakerboxConfiguration;
import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ArchaiusPropertyRegister {
    private static class TenacityPollingScheduler extends FixedDelayPollingScheduler {
        private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPollingScheduler.class);

        public TenacityPollingScheduler(int initialDelayMillis, int delayMillis, boolean ignoreDeletesFromSource) {
            super(initialDelayMillis, delayMillis, ignoreDeletesFromSource);
        }

        @Override
        protected synchronized void initialLoad(PolledConfigurationSource source, Configuration config) {
            try {
                super.initialLoad(source, config);
            } catch (Exception err) {
                LOGGER.warn("Initial dynamic configuration load failed", err);
            }
        }
    }
    public void register(BreakerboxConfiguration breakerboxConfiguration) {
        if (breakerboxConfiguration.getUrls().isEmpty()) {
            return;
        }
        ConfigurationManager.install(
                new DynamicConfiguration(
                    new URLConfigurationSource(breakerboxConfiguration.getUrls().split(",")),
                    new TenacityPollingScheduler(
                            (int)breakerboxConfiguration.getInitialDelay().toMilliseconds(),
                            (int)breakerboxConfiguration.getDelay().toMilliseconds(),
                            true)));
    }
}

Add some braces around an if guard

Add some braces around an if guard


package com.github.dieterdepaepe.jsearch.search.statespace;

/**
 * A node encountered in the search graph while solving a problem.
 *

 * There is a subtle but important difference between a {@code SearchNode} and a search space state. A search space
 * state represents the result from a set of chosen actions. A {@code SearchNode} represents a result, but also
 * information regarding the path found to that search space state (most notably the cost needed to reach that state).
 * While the state space for a certain problem can be either a tree or a graph, the search graph is always a tree.
 *
 *
Implementation note:

 * Each implementation will be specific for a certain kind of problem being solved.
 * It is recommended to store only node-specific information, any information that is shared between nodes
 * should be stored in the problem environment (as described in {@link SearchNodeGenerator}).
 *
 * @author Dieter De Paepe
 */
public interface SearchNode {
    /**
     * Indicates whether this node is a solution.
     * @return true if it is a solution
     */
    public boolean isGoal();

    /**
     * Returns the exact cost associated with this search node.
     * @return the cost
     */
    public double getCost();
}

package com.github.dieterdepaepe.jsearch.search.statespace;

/**
 * A node encountered in the search graph while solving a problem.
 *

 * There is a subtle but important difference between a {@code SearchNode} and a search space state. A search space
 * state represents the result from a set of chosen actions. A {@code SearchNode} represents a result, but also
 * information regarding the path found to that search space state (most notably the cost needed to reach that state).
 * While the state space for a certain problem can be either a tree or a graph, the search graph is always a tree.
 *
 *
Implementation note:

 * Each implementation will be specific for a certain kind of problem being solved.
 * It is recommended to store only node-specific information, any information that is shared between nodes
 * should be stored in the problem environment (as described in {@link SearchNodeGenerator}).
 *
 * @author Dieter De Paepe
 */
public interface SearchNode {
    /**
     * Indicates whether this node is a solution.
     * @return true if it is a solution
     */
    public boolean isGoal();

    /**
     * Returns the exact cost associated with this search node.
     * @return the cost
     */
    public double getCost();

    /**
     * Returns a (lightweight) object that represents the search space state that has been reached by this node.
     *

     * When 2 {@code SearchNode}s have an {@code equal} search space state, the most expensive node can be dropped
     * from the search by a solver.
     * @return a non-null object
     */
    public Object getSearchSpaceState();
}

Add lightweight method for detecting duplicate search nodes.


package org.realityforge.replicant.example.client;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * Callback invoked on completion of every job
 */
public class GlobalAsyncCallback
  implements AsyncCallback
{
  @Override
  public void onFailure( final Throwable caught )
  {
    Window.alert( "Failed!" );
  }

  @Override
  public void onSuccess( final Object result )
  {
  }
}

package org.realityforge.replicant.example.client;

import com.google.gwt.user.client.rpc.AsyncCallback;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Callback invoked on completion of every job
 */
public class GlobalAsyncCallback
  implements AsyncCallback
{
  private static final Logger LOG = Logger.getLogger( GlobalAsyncCallback.class.getName() );

  @Override
  public void onFailure( final Throwable caught )
  {
    LOG.log( Level.WARNING, "A request failed", caught );
  }

  @Override
  public void onSuccess( final Object result )
  {
    LOG.log( Level.INFO, "A request succeeded: " + result );
  }
}

Rework callback so that it emits logs to the console. Less annoying than popups


package org.wikipedia.feed.aggregated;

import android.support.annotation.Nullable;

import com.google.gson.annotations.SerializedName;

import org.wikipedia.feed.model.CardPageItem;
import org.wikipedia.feed.mostread.MostReadArticles;
import org.wikipedia.feed.news.NewsItem;
import org.wikipedia.feed.image.FeaturedImage;

import java.util.List;

public class AggregatedFeedContent {
    @SuppressWarnings("unused") @Nullable private CardPageItem tfa;
    @SuppressWarnings("unused") @Nullable private List<NewsItem> news;
    @SuppressWarnings("unused") @Nullable private CardPageItem random;
    @SuppressWarnings("unused") @SerializedName("mostread") @Nullable private MostReadArticles mostRead;
    @SuppressWarnings("unused") @Nullable private FeaturedImage image;

    @Nullable
    public CardPageItem tfa() {
        return tfa;
    }

    @Nullable
    public List<NewsItem> news() {
        return news;
    }

    @Nullable
    public MostReadArticles mostRead() {
        return mostRead;
    }

    @Nullable
    public FeaturedImage potd() {
        return image;
    }
}

package org.wikipedia.feed.aggregated;

import android.support.annotation.Nullable;

import com.google.gson.annotations.SerializedName;

import org.wikipedia.feed.model.CardPageItem;
import org.wikipedia.feed.mostread.MostReadArticles;
import org.wikipedia.feed.news.NewsItem;
import org.wikipedia.feed.image.FeaturedImage;

import java.util.List;

public class AggregatedFeedContent {
    @SuppressWarnings("unused") @Nullable private CardPageItem tfa;
    @SuppressWarnings("unused") @Nullable private List<NewsItem> news;
    @SuppressWarnings("unused") @SerializedName("mostread") @Nullable private MostReadArticles mostRead;
    @SuppressWarnings("unused") @Nullable private FeaturedImage image;

    @Nullable
    public CardPageItem tfa() {
        return tfa;
    }

    @Nullable
    public List<NewsItem> news() {
        return news;
    }

    @Nullable
    public MostReadArticles mostRead() {
        return mostRead;
    }

    @Nullable
    public FeaturedImage potd() {
        return image;
    }
}

Remove random from aggregated feed parsing

We had random data display in earlier versions of the app but don't actually use it.
During an RB deploy today where we wanted to change the format to an array
we discovered that the app was still expecting the random property to be an object.

Therefore let's remove the random property from even being read in
to allow for more flexibility in the future.

Change-Id: I56a33249d0083c88eec3254aca9173a7c8edfbd6


package com.relayrides.pushy.apns;

import io.netty.handler.ssl.OpenSsl;
import io.netty.handler.ssl.SslProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Utility class for choosing SSL providers.
 *
 * @author Jon Chambers
 *
 * @since 0.10
 */
class SslUtil {

    private static final Logger log = LoggerFactory.getLogger(SslUtil.class);

    /**
     * Selects an SSL provider based on the availability of of an ALPN-capable native provider.
     *
     * @return an ALPN-capable native SSL provider if available, or else the JDK SSL provider
     */
    public static SslProvider getSslProvider() {
        final SslProvider sslProvider;

        if (OpenSsl.isAvailable()) {
            if (OpenSsl.isAlpnSupported()) {
                log.info("Native SSL provider is available and supports ALPN; will use native provider.");
                sslProvider = SslProvider.OPENSSL;
            } else {
                log.info("Native SSL provider is available, but does not support ALPN; will use JDK SSL provider.");
                sslProvider = SslProvider.JDK;
            }
        } else {
            log.info("Native SSL provider not available; will use JDK SSL provider.");
            sslProvider = SslProvider.JDK;
        }

        return sslProvider;
    }
}

package com.relayrides.pushy.apns;

import io.netty.handler.ssl.OpenSsl;
import io.netty.handler.ssl.SslProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Utility class for choosing SSL providers.
 *
 * @author Jon Chambers
 *
 * @since 0.10
 */
class SslUtil {

    private static final Logger log = LoggerFactory.getLogger(SslUtil.class);

    /**
     * Selects an SSL provider based on the availability of of an ALPN-capable native provider.
     *
     * @return an ALPN-capable native SSL provider if available, or else the JDK SSL provider
     */
    public static SslProvider getSslProvider() {
        final SslProvider sslProvider;

        if (OpenSsl.isAvailable()) {
            if (OpenSsl.isAlpnSupported()) {
                log.info("Native SSL provider is available and supports ALPN; will use native provider.");
                sslProvider = SslProvider.OPENSSL_REFCNT;
            } else {
                log.info("Native SSL provider is available, but does not support ALPN; will use JDK SSL provider.");
                sslProvider = SslProvider.JDK;
            }
        } else {
            log.info("Native SSL provider not available; will use JDK SSL provider.");
            sslProvider = SslProvider.JDK;
        }

        return sslProvider;
    }
}

Use OPENSSL_REFCNT instead of OPENSSL as our SSL provider when possible.


package com.asesolution.mobile.lorempixel.utils;

import android.graphics.Bitmap;
import android.graphics.Color;

import com.asesolution.mobile.lorempixel.utils.picasso.PaletteTransformation;

public class PaletteUtils {
    private static final int DEFAULT_COLOR = Color.parseColor("#757575");
    private static final int DEFAULT_ALPHA = 170; // 255 * 2 / 3

    public static int getPaletteColor(Bitmap bitmap) {
        int color = PaletteTransformation.getPalette(bitmap).getDarkVibrantColor(DEFAULT_COLOR);

        // Add some transparency. This kind of sucks and it's a little cleaner/faster
        // to just use bitwise operations, but I'm going for a readability here
        return Color.argb(DEFAULT_ALPHA, Color.red(color), Color.green(color), Color.blue(color));
    }
}

package com.asesolution.mobile.lorempixel.utils;

import android.graphics.Bitmap;
import android.graphics.Color;

import com.asesolution.mobile.lorempixel.MainApplication;
import com.asesolution.mobile.lorempixel.R;
import com.asesolution.mobile.lorempixel.utils.picasso.PaletteTransformation;

public class PaletteUtils {
    private static final int DEFAULT_COLOR = MainApplication.getStaticResources().getColor(R.color.md_grey_600, null);
    private static final int DEFAULT_ALPHA = 170; // 255 * 2 / 3

    public static int getPaletteColor(Bitmap bitmap) {
        int color = PaletteTransformation.getPalette(bitmap).getDarkVibrantColor(DEFAULT_COLOR);

        // Add some transparency. This kind of sucks and it's a little cleaner/faster
        // to just use bitwise operations, but I'm going for a readability here
        return Color.argb(DEFAULT_ALPHA, Color.red(color), Color.green(color), Color.blue(color));
    }
}

Update upaletteutils to source default color from colors.xml


package com.i906.mpt.date;

import java.util.Calendar;
import java.util.TimeZone;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * @author Noorzaini Ilhami
 */
@Singleton
class DateProvider {

    private final Calendar mCalendar;

    @Inject
    DateProvider() {
        mCalendar = getCalendarInstance();
    }

    private void refresh() {
        mCalendar.setTimeInMillis(getCurrentTime());
    }

    public long getCurrentTime() {
        return System.currentTimeMillis();
    }

    public Calendar getNow() {
        refresh();
        return mCalendar;
    }

    public Calendar getCalendarInstance() {
        return Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
    }
}

package com.i906.mpt.date;

import java.util.Calendar;
import java.util.TimeZone;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * @author Noorzaini Ilhami
 */
@Singleton
class DateProvider {

    private Calendar mCalendar;

    @Inject
    DateProvider() {
    }

    private void refresh() {
        mCalendar = getCalendarInstance();
    }

    public long getCurrentTime() {
        return System.currentTimeMillis();
    }

    public Calendar getNow() {
        refresh();
        return mCalendar;
    }

    public Calendar getCalendarInstance() {
        return Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
    }
}

Fix random wrong month or year in prayer times


/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.spine3.base;

import com.google.common.base.Converter;

/**
 * Serves as converter from {@code I} to {@code String} with an associated
 * reverse function from {@code String} to {@code I}.
 *
 * <p>It is used for converting back and forth between the different
 * representations of the same information.
 *
 * @author Alexander Yevsyukov
 * @see #convert(Object)
 * @see #reverse()
 */
public abstract class Stringifier<I> extends Converter<I, String> {
}

/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.spine3.base;

import com.google.common.base.Converter;

/**
 * Serves as converter from {@code I} to {@code String} with an associated
 * reverse function from {@code String} to {@code I}.
 *
 * <p>It is used for converting back and forth between the different
 * representations of the same information.
 *
 * @author Alexander Yevsyukov
 * @author Illia Shepilov
 * @see #convert(Object)
 * @see #reverse()
 */
public abstract class Stringifier<I> extends Converter<I, String> {
}

Add the `author` annotation in the documentation.


package buildr.ipojo.cli;

import java.io.File;
import java.io.FileInputStream;
import org.apache.felix.ipojo.manipulator.Pojoization;

public class Main
{
  public static void main( final String[] args )
  {
    if( 4 != args.length )
    {
      System.err.println("Usage: <input_file_name> <output_file_name> <metadata_file_name> <print_trace_messages?>");
      System.exit( 42 );
    }
    final String inputFilename = args[0];
    final String outputFilename = args[1];
    final String metadataFilename = args[2];
    final boolean printTraceMessage = args[3].equals( "true" );
    boolean inError;

    try
    {
      final Pojoization pojoizer = new Pojoization();
      pojoizer.setUseLocalXSD();
      pojoizer.pojoization( new File( inputFilename ),
                            new File( outputFilename ),
                            new FileInputStream( metadataFilename ) );
      if( printTraceMessage )
      {
        for( final Object message : pojoizer.getWarnings() )
        {
          System.out.println( "Pojoizer Warning: " + message );
        }
      }

      inError = pojoizer.getWarnings().size() != 0;
      for( final Object message : pojoizer.getWarnings() )
      {
        System.err.println( "Pojoizer Error: " + message );
      }
    }
    catch( final Exception e )
    {
      e.printStackTrace( System.err );
      inError = true;
    }

    System.exit( inError ? 1 : 0 );
  }
}

package buildr.ipojo.cli;

import java.io.File;
import java.io.FileInputStream;
import org.apache.felix.ipojo.manipulator.Pojoization;

public class Main
{
  public static void main( final String[] args )
  {
    if( 4 != args.length )
    {
      System.err.println("Usage: <input_file_name> <output_file_name> <metadata_file_name> <print_trace_messages?>");
      System.exit( 42 );
    }
    final String inputFilename = args[0];
    final String outputFilename = args[1];
    final String metadataFilename = args[2];
    final boolean printTraceMessage = args[3].equals( "true" );
    boolean inError;

    try
    {
      final Pojoization pojoizer = new Pojoization();
      pojoizer.setUseLocalXSD();
      pojoizer.pojoization( new File( inputFilename ),
                            new File( outputFilename ),
                            new FileInputStream( metadataFilename ) );
      if( printTraceMessage )
      {
        for( final Object message : pojoizer.getWarnings() )
        {
          System.out.println( "Pojoizer Warning: " + message );
        }
      }

      inError = pojoizer.getErrors().size() != 0;
      for( final Object message : pojoizer.getErrors() )
      {
        System.err.println( "Pojoizer Error: " + message );
      }
    }
    catch( final Exception e )
    {
      e.printStackTrace( System.err );
      inError = true;
    }

    System.exit( inError ? 1 : 0 );
  }
}

Fix bug where warnings were being printed as errors


/*******************************************************************************
 * Copyright (c) 2014 Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package com.codenvy.ide.editor.orion.client;

import javax.inject.Inject;

import com.codenvy.ide.Resources;
import com.codenvy.ide.dto.DtoFactory;
import com.codenvy.ide.editor.common.client.texteditor.EditorWidgetFactory;
import com.codenvy.ide.editor.common.client.texteditor.EmbeddedTextEditorPartView;
import com.codenvy.ide.editor.common.client.texteditor.EmbeddedTextEditorPartViewImpl;
import com.codenvy.ide.editor.common.client.texteditor.EmbeddedTextEditorViewFactory;

public class OrionTextEditorViewFactory implements EmbeddedTextEditorViewFactory {

    @Inject
    private EditorWidgetFactory<OrionEditorWidget> widgetFactory;

    @Override
    public EmbeddedTextEditorPartView createTextEditorPartView(final Resources resources, DtoFactory dtoFactory) {
        return new EmbeddedTextEditorPartViewImpl<OrionEditorWidget>(this.widgetFactory);
    }
}

/*******************************************************************************
 * Copyright (c) 2014 Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package com.codenvy.ide.editor.orion.client;

import javax.inject.Inject;

import com.codenvy.ide.editor.common.client.filetype.FileTypeIdentifier;
import com.codenvy.ide.editor.common.client.texteditor.EditorWidgetFactory;
import com.codenvy.ide.editor.common.client.texteditor.EmbeddedTextEditorPartView;
import com.codenvy.ide.editor.common.client.texteditor.EmbeddedTextEditorPartViewImpl;
import com.codenvy.ide.editor.common.client.texteditor.EmbeddedTextEditorViewFactory;

public class OrionTextEditorViewFactory implements EmbeddedTextEditorViewFactory {

    @Inject
    private EditorWidgetFactory<OrionEditorWidget> widgetFactory;
    @Inject
    private FileTypeIdentifier                     fileTypeIdentifier;

    @Override
    public EmbeddedTextEditorPartView createTextEditorPartView() {
        return new EmbeddedTextEditorPartViewImpl<OrionEditorWidget>(this.widgetFactory, this.fileTypeIdentifier);
    }
}

Update the factory after common js editor change


package io.gatekeeper.node.service.replication;

import io.gatekeeper.configuration.Configuration;
import io.gatekeeper.configuration.data.replication.LocalReplicationConfiguration;
import io.gatekeeper.model.Endpoint;
import io.gatekeeper.node.service.ReplicationService;
import io.gatekeeper.node.service.replication.common.Node;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

public class LocalReplicationService extends ReplicationService<LocalReplicationConfiguration> {

    public LocalReplicationService(Configuration configuration) {
        super(configuration);
    }

    @Override
    public CompletableFuture<Void> start() {
        return CompletableFuture.completedFuture(null);
    }

    @Override
    public CompletableFuture<Integer> countNodes() {
        return CompletableFuture.completedFuture(1);
    }

    @Override
    public CompletableFuture<List<Node>> fetchNodes() {
        return CompletableFuture.completedFuture(Collections.singletonList(new Node(
            "local",
            replicationConfiguration.rpcAddress,
            replicationConfiguration.rpcPort
        )));
    }

    @Override
    public void close() throws IOException {
        super.close();
    }
}

package io.gatekeeper.node.service.replication;

import io.gatekeeper.configuration.Configuration;
import io.gatekeeper.configuration.data.replication.LocalReplicationConfiguration;
import io.gatekeeper.node.service.ReplicationService;
import io.gatekeeper.node.service.replication.common.Node;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public class LocalReplicationService extends ReplicationService<LocalReplicationConfiguration> {

    public LocalReplicationService(Configuration configuration) {
        super(configuration);
    }

    @Override
    public CompletableFuture<Void> start() {
        return CompletableFuture.completedFuture(null);
    }

    @Override
    public CompletableFuture<Integer> countNodes() {
        return CompletableFuture.completedFuture(1);
    }

    @Override
    public CompletableFuture<List<Node>> fetchNodes() {
        return CompletableFuture.completedFuture(Collections.singletonList(new Node(
            "local",
            replicationConfiguration.rpcAddress,
            replicationConfiguration.rpcPort
        )));
    }

    @Override
    public void close() throws IOException {
        super.close();
    }
}

Clean up imports from local replication service


/*
 * Copyright 2015 Google Inc. 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 com.google.gcloud.storage;

/**
 * Http method supported by Storage service.
 */
public enum HttpMethod {
  GET, HEAD, PUT, POST, DELETE
}

/*
 * Copyright 2015 Google Inc. 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 com.google.gcloud.storage;

/**
 * Http method supported by Storage service.
 */
public enum HttpMethod {
  GET, HEAD, PUT, POST, DELETE, OPTIONS
}

Fix IllegalArgumentException when OPTIONS in cors


/*
 * JBoss, Home of Professional Open Source
 * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * 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.hibernate.validator.util;

/**
 * @author Hardy Ferentschik
 */
public final class Version {
	static {
		LoggerFactory.make().info( "Hibernate Search {}", getVersionString() );
	}

	public static String getVersionString() {
		return "[WORKING]";
	}

	public static void touch() {
	}

	// helper class should not have a public constructor
	private Version() {
	}
}

/*
 * JBoss, Home of Professional Open Source
 * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * 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.hibernate.validator.util;

/**
 * @author Hardy Ferentschik
 */
public final class Version {
	static {
		LoggerFactory.make().info( "Hibernate Validator {}", getVersionString() );
	}

	public static String getVersionString() {
		return "[WORKING]";
	}

	public static void touch() {
	}

	// helper class should not have a public constructor
	private Version() {
	}
}

HV-426: Use Hibernate Validator in version logging message.


package roart.common.util;

import java.io.InputStream;

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

import roart.common.constants.Constants;

public class IOUtil {
    private static Logger log = LoggerFactory.getLogger(IOUtil.class);

    public static byte[] toByteArrayMax(InputStream is) {
        try {
            return is.readNBytes(Integer.MAX_VALUE - 8);
        } catch (Exception e) {
            log.error(Constants.EXCEPTION, e);
            return new byte[0];
        }
    }

    public static byte[] toByteArray1G(InputStream is) {
        try {
            return is.readNBytes(1024 * 1024 * 1024);
        } catch (Exception e) {
            log.error(Constants.EXCEPTION, e);
            return new byte[0];
        }
    }
}

package roart.common.util;

import java.io.InputStream;

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

import roart.common.constants.Constants;

public class IOUtil {
    private static Logger log = LoggerFactory.getLogger(IOUtil.class);

    public static byte[] toByteArrayMax(InputStream is) {
        try {
            return is.readNBytes(Integer.MAX_VALUE - 8);
        } catch (Exception e) {
            log.error(Constants.EXCEPTION, e);
            return new byte[0];
        }
    }

    public static byte[] toByteArray1G(InputStream is) {
        try {
            return is.readNBytes(1024 * 1024 * 1024);
        } catch (Exception e) {
            log.error(Constants.EXCEPTION, e);
            return new byte[0];
        }
    }

    public static byte[] toByteArray(InputStream is, int bytes) {
        try {
            return is.readNBytes(bytes);
        } catch (Exception e) {
            log.error(Constants.EXCEPTION, e);
            return new byte[0];
        }
    }
}

Index size check, for Elastic 8 upgrade (I10).


package au.gov.ga.geodesy.domain.model.event;

import java.time.Instant;
import java.util.Calendar;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

public class EventRepositoryImpl implements EventRepositoryCustom {

    @PersistenceContext(unitName = "geodesy")
    private EntityManager entityManager;

    public List<Event> getPendingEvents() {

        // TODO: try to remove oneMinuteAgo
        String queryString = "select e from Event e "
            + "where e.timeHandled is null and (e.retries is null or e.retries < " + Event.MAX_RETRIES + ") and (e.timePublished is null or e.timePublished < :oneMinuteAgo)";

        TypedQuery<Event> query = entityManager.createQuery(queryString, Event.class);
        Calendar c = Calendar.getInstance();
        c.add(Calendar.MINUTE, -1);
        query.setParameter("oneMinuteAgo", c.getTime());
        return query.getResultList();
    }
}

package au.gov.ga.geodesy.domain.model.event;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

public class EventRepositoryImpl implements EventRepositoryCustom {

    @PersistenceContext(unitName = "geodesy")
    private EntityManager entityManager;

    // TODO: move out of custom
    public List<Event> getPendingEvents() {

        String queryString = "select e from Event e "
            + "where e.timeHandled is null and (e.retries is null or e.retries < " + Event.MAX_RETRIES + ") and (e.timePublished is null)";

        TypedQuery<Event> query = entityManager.createQuery(queryString, Event.class);
        return query.getResultList();
    }
}

Remove recently published test for pending events


/*
 * Licensed to Crate under one or more contributor license agreements.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.  Crate 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.
 *
 * However, if you have executed another commercial license agreement
 * with Crate these terms will supersede the license and you may use the
 * software solely pursuant to the terms of the relevant commercial
 * agreement.
 */

package io.crate.testing;

import org.hamcrest.Matcher;
import org.junit.jupiter.api.function.Executable;
import org.opentest4j.AssertionFailedError;

public class Asserts {

    private Asserts() {}

    public static <T extends Throwable> void assertThrows(Executable executable, Matcher<T> matcher) {
        try {
            executable.execute();
        } catch (Throwable t) {
            if (matcher.matches(t)) {
                return;
            }
            throw new AssertionFailedError(
                String.format("Unmatched %s type thrown with message '%s'",
                              t.getClass().getCanonicalName(),
                              t.getMessage()), t);
        }
        throw new AssertionFailedError("Expected exception to be thrown, but nothing was thrown.");
    }
}

/*
 * Licensed to Crate under one or more contributor license agreements.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.  Crate 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.
 *
 * However, if you have executed another commercial license agreement
 * with Crate these terms will supersede the license and you may use the
 * software solely pursuant to the terms of the relevant commercial
 * agreement.
 */

package io.crate.testing;

import static org.hamcrest.MatcherAssert.assertThat;

import org.hamcrest.Matcher;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.function.Executable;

public class Asserts {

    private Asserts() {}

    public static void assertThrows(Executable executable, Matcher<? super Throwable> matcher) {
        try {
            executable.execute();
            Assertions.fail("Expected exception to be thrown, but nothing was thrown.");
        } catch (Throwable t) {
            assertThat(t, matcher);
        }
    }
}

Use junit assertions in assertThrows

Use junit assertions in assertThrows

I was wondering where a opentest4j error came from.
This changes the newly introduced assertThrows to use the same
verification mechanism we use everywhere else.


package seedu.todo.guitests;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class ConsoleTest extends GuiTest {

    @Test
    public void testValidCommand_consoleInputCleared() {
        console.runCommand("list");
        assertEquals(console.getConsoleInputText(), "");
    }

}

package seedu.todo.guitests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

import org.junit.Test;

public class ConsoleTest extends GuiTest {

    @Test
    public void testValidCommand_consoleInputCleared() {
        console.runCommand("list");
        assertEquals(console.getConsoleInputText(), "");
    }

    @Test
    public void testInvalidCommand_consoleInputRemains() {
        console.runCommand("invalidcommand");
        assertNotEquals(console.getConsoleInputText(), "");
    }

}

Add invalid command console test

Add invalid command console test


package seedu.tasklist.commons.core;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class ConfigTest {
    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Test
    public void toString_defaultObject_stringReturned() {
        String defaultConfigAsString = "App title : FlexiTask\n" +
                "Current log level : INFO\n" +
                "Preference file Location : preferences.json\n" +
                "Local data file location : data/tasklist.xml\n" +
                "TaskList name : MyTaskList";

        assertEquals(defaultConfigAsString, new Config().toString());
    }

    @Test
    public void equalsMethod() {
        Config defaultConfig = new Config();
        assertNotNull(defaultConfig);
        assertTrue(defaultConfig.equals(defaultConfig));
    }

}

package seedu.tasklist.commons.core;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class ConfigTest {
    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Test
    public void toString_defaultObject_stringReturned() {
        String defaultConfigAsString = "App title : FlexiTask\n" +
                "Current log level : INFO\n" +
                "Preference file Location : preferences.json\n" +
                "Local data file location : data/tasklist.xml\n" +
                "TaskList name : MyTaskList";

        assertEquals(defaultConfigAsString, new Config().toString());
    }

    @Test
    public void equalsMethod() {
        Config defaultConfig = new Config();
        assertNotNull(defaultConfig);
        assertTrue(defaultConfig.equals(defaultConfig));

        Config config = new Config();
        assertFalse(config.equals("MyTaskList"));
    }

    //@@author A0141993X
    @Test
    public void hashCodeMethod() {
        Config defaultConfig = new Config();
        assertEquals(defaultConfig.hashCode(), defaultConfig.hashCode());

        Config config = new Config();
        assertEquals(config.hashCode(), defaultConfig.hashCode());
    }

}

Add test to improve code coverage

Add test to improve code coverage


package com.google.sps.data;

import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.keyvalue.MultiKey;

/*
 * Class representing one row/entry in the aggregation response.  A NULL field value
 * means the field was not being aggregated by, and will be omitted from the JSON response
*/
public final class AggregationResponseEntry {

  private String assetId;
  private String location;
  private String user;
  private final int count;

  public AggregationResponseEntry(MultiKey key, int count, Set<AnnotatedField> fields) {

    String keys[] = (String[]) key.getKeys();
    int currKey = 0;

    Iterator<AnnotatedField> it = fields.iterator();
    while (it.hasNext()) {
      switch(it.next()) {
        case ASSET_ID:
          this.assetId = keys[currKey++];
          break;
        case LOCATION:
          this.location = keys[currKey++];
          break;
        case USER:
          this.user = keys[currKey++];
          break;
      }
    }

    this.count = count;
  }
}

package com.google.sps.data;

import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.keyvalue.MultiKey;

/*
 * Class representing one row/entry in the aggregation response.  A NULL field value
 * means the field was not being aggregated by, and will be omitted from the JSON response
*/
public final class AggregationResponseEntry {

  private String annotatedAssetId;
  private String annotatedLocation;
  private String annotatedUser;
  private final int count;

  public AggregationResponseEntry(MultiKey key, int count, Set<AnnotatedField> fields) {

    String keys[] = (String[]) key.getKeys();
    int currKey = 0;

    Iterator<AnnotatedField> it = fields.iterator();
    while (it.hasNext()) {
      switch(it.next()) {
        case ASSET_ID:
          this.annotatedAssetId = keys[currKey++];
          break;
        case LOCATION:
          this.annotatedLocation = keys[currKey++];
          break;
        case USER:
          this.annotatedUser = keys[currKey++];
          break;
      }
    }

    this.count = count;
  }
}

Refactor output format to be same as input format, standardizing the API


/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.translator.language;

import cx2x.xcodeml.exception.IllegalDirectiveException;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;

/**
 * Listener that save the last error information from the CLAW language parser.
 *
 * @author clementval
 */
public class ClawErrorListener extends BaseErrorListener {

  private static IllegalDirectiveException ex = null;

  /**
   * Default ctor
   */
  public ClawErrorListener(){}

  @Override
  public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol,
                          int line, int charPositionInLine,
                          String msg, RecognitionException e)
  {
    ex = new IllegalDirectiveException("", msg, line, charPositionInLine);
  }

  /**
   * Get the last error information.
   * @return IllegalDirectiveException encapsulating the last error information.
   */
  IllegalDirectiveException getLastError(){
      return ex;
    }

}

/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.translator.language;

import cx2x.xcodeml.exception.IllegalDirectiveException;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;

/**
 * Listener that save the last error information from the CLAW language parser.
 *
 * @author clementval
 */
public class ClawErrorListener extends BaseErrorListener {

  private static IllegalDirectiveException ex = null;

  /**
   * Default ctor
   */
  public ClawErrorListener() {
  }

  @Override
  public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol,
                          int line, int charPositionInLine,
                          String msg, RecognitionException e)
  {
    ex = new IllegalDirectiveException("", msg, line, charPositionInLine);
  }

  /**
   * Get the last error information.
   *
   * @return IllegalDirectiveException encapsulating the last error information.
   */
  public IllegalDirectiveException getLastError() {
    return ex;
  }

}

Update modifier + code style

Update modifier + code style


package org.usfirst.frc4909.STEAMWORKS.commands;

import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

import org.usfirst.frc4909.STEAMWORKS.Robot;

public class DriveCommand extends Command {
    public DriveCommand() {
        requires(Robot.drivetrain);
    }

    protected void initialize() {}

    protected void execute() {
    	Robot.drivetrain.moveTank();
    	/*
		SmartDashboard.putNumber("X dist",Robot.drivetrain.getDisplacementX());
		SmartDashboard.putNumber("Y dist",Robot.drivetrain.getDisplacementY());
		SmartDashboard.putNumber("Z dist",Robot.drivetrain.getDisplacementZ());
		*/

		SmartDashboard.putNumber("Left dist",Robot.drivetrain.getLeftEncDistance());
		SmartDashboard.putNumber("Right dist",Robot.drivetrain.getRightEncDistance());
    }

    protected boolean isFinished() {
        return false;
    }

    protected void end() {
    	Robot.drivetrain.stop();
    }

    protected void interrupted() {
    	end();
    }
}

package org.usfirst.frc4909.STEAMWORKS.commands;

import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

import org.usfirst.frc4909.STEAMWORKS.Robot;

public class DriveCommand extends Command {
    public DriveCommand() {
        requires(Robot.drivetrain);
    }

    protected void initialize() {}

    protected void execute() {
    	Robot.drivetrain.moveTank();
    }

    protected boolean isFinished() {
        return false;
    }

    protected void end() {
    	Robot.drivetrain.stop();
    }

    protected void interrupted() {
    	end();
    }
}

Remove SmartDashboard Data for Teleop. Drive


package ru.faulab.attendence;

import com.google.inject.Guice;
import com.google.inject.Injector;
import ru.faulab.attendence.module.MainModule;
import ru.faulab.attendence.ui.MainFrame;

public class Runner {

    /*
    * 1. Статистика
    * */
    public static void main(String[] args) throws Exception {

        String userHome = System.getProperty("user.home");
        System.setProperty("derby.system.home", userHome);

        Injector injector = Guice.createInjector(new MainModule());

        MainFrame mainFrame = injector.getInstance(MainFrame.class);
        mainFrame.init();
    }

}

package ru.faulab.attendence;

import com.google.inject.Guice;
import com.google.inject.Injector;
import ru.faulab.attendence.module.MainModule;
import ru.faulab.attendence.ui.MainFrame;

import javax.swing.*;

public class Runner {

    /*
    * 1. Статистика
    * */
    public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);

        String userHome = System.getProperty("user.home");
        System.setProperty("derby.system.home", userHome);

        Injector injector = Guice.createInjector(new MainModule());

        MainFrame mainFrame = injector.getInstance(MainFrame.class);
        mainFrame.init();
    }

}

Set UI as best on OS

Set UI as best on OS


package com.robrua.orianna.type.core.common;

import java.util.HashMap;
import java.util.Map;

public enum GameMap {
    HOWLING_ABYSS(12), SUMMONERS_RIFT(11), SUMMONERS_RIFT_AUTUMN(2), SUMMONERS_RIFT_SUMMER(1), THE_CRYSTAL_SCAR(8), THE_PROVING_GROUNDS(3), TWISTED_TREELINE(10), TWISTED_TREELINE_ORIGINAL(
            4);

    private static final Map<Long, GameMap> IDs = new HashMap<>();
    static {
        for(final GameMap m : GameMap.values()) {
            IDs.put(m.ID, m);
        }
    }

    /**
     * Gets the map for a specified ID
     *
     * @param ID
     *            the map ID
     * @return the map type
     */
    public static GameMap forID(final long ID) {
        return IDs.get(ID);
    }

    private final Long ID;

    /**
     * @param ID
     */
    private GameMap(final long ID) {
        this.ID = ID;
    }

    /**
     * Gets the ID for this map
     *
     * @return the ID for this map
     */
    public long getID() {
        return ID;
    }
}

package com.robrua.orianna.type.core.common;

import java.util.HashMap;
import java.util.Map;

public enum GameMap {
    BUTCHERS_BRIDGE(14), HOWLING_ABYSS(12), SUMMONERS_RIFT(11), SUMMONERS_RIFT_AUTUMN(2), SUMMONERS_RIFT_SUMMER(1), THE_CRYSTAL_SCAR(8), THE_PROVING_GROUNDS(3), TWISTED_TREELINE(10), TWISTED_TREELINE_ORIGINAL(
            4);

    private static final Map<Long, GameMap> IDs = new HashMap<>();
    static {
        for(final GameMap m : GameMap.values()) {
            IDs.put(m.ID, m);
        }
    }

    /**
     * Gets the map for a specified ID
     *
     * @param ID
     *            the map ID
     * @return the map type
     */
    public static GameMap forID(final long ID) {
        return IDs.get(ID);
    }

    private final Long ID;

    /**
     * @param ID
     */
    private GameMap(final long ID) {
        this.ID = ID;
    }

    /**
     * Gets the ID for this map
     *
     * @return the ID for this map
     */
    public long getID() {
        return ID;
    }
}

Add bildge water event map name

Add bildge water event map name

my app was crashing and it may come in handy later if the event repeats.


package li.l1t.tingo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Controls displaying of error messages.
 *
 * @author xxyy
 * @since 7.4.16
 */
@Controller
public class TingoErrorController implements ErrorController {
    private static final String ERROR_PATH = "/error";

    @Autowired
    private ErrorAttributes errorAttributes;

    @Override
    public String getErrorPath() {
        return ERROR_PATH;
    }

    @RequestMapping(value = ERROR_PATH)
    public String errorHtml(HttpServletRequest request, Model model) {
        Object errCodeObj = request.getAttribute("javax.servlet.error.status_code");
        int errorCode = errCodeObj == null ? 0 : (int) errCodeObj;
        model.addAttribute("errorCode", errCodeObj);
        model.addAttribute("errorType", request.getAttribute("javax.servlet.error.exception"));

        switch(errorCode) {
            case 401:
                return "error/401.html";
            case 0:
            default:
                return "error/generic.html";
        }
    }
}

package li.l1t.tingo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Controls displaying of error messages.
 *
 * @author xxyy
 * @since 7.4.16
 */
@Controller
public class TingoErrorController implements ErrorController {
    private static final String ERROR_PATH = "/error";

    @Autowired
    private ErrorAttributes errorAttributes;

    @Override
    public String getErrorPath() {
        return ERROR_PATH;
    }

    @RequestMapping(value = ERROR_PATH)
    public String errorHtml(HttpServletRequest request, Model model) {
        Object errCodeObj = request.getAttribute("javax.servlet.error.status_code");
        int errorCode = errCodeObj == null ? 0 : (int) errCodeObj;
        model.addAttribute("errorCode", errCodeObj);
        model.addAttribute("errorType", request.getAttribute("javax.servlet.error.exception"));

        switch(errorCode) {
            case 401:
                return "error/401";
            case 0:
            default:
                return "error/generic";
        }
    }
}

Fix wrong template usage in error pages

Fix wrong template usage in error pages


package org.mastercoin.rpc;

import com.google.bitcoin.core.Address;

import java.math.BigDecimal;

/**
 * Balance data for a specific Mastercoin CurrencyID in a single Bitcoin address
 *
 * A Java representation of the JSON entry returned by getallbalancesforid_MP
 */
public class MPBalanceEntry {
    private Address address;
    private BigDecimal balance;
    private BigDecimal reserved;

    public MPBalanceEntry(Address address, BigDecimal balance, BigDecimal reserved) {
        this.address = address;
        this.balance = balance;
        this.reserved = reserved;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof MPBalanceEntry)) {
            return false;
        }
        MPBalanceEntry e = (MPBalanceEntry) o;
        if (    (this.address == e.address) &&
                (this.balance == e.balance) &&
                (this.reserved == e.reserved) ) {
            return true;
        } else {
            return false;
        }
    }

    public Address getAddress() {
        return address;
    }

    public BigDecimal getBalance() {
        return balance;
    }

    public BigDecimal getReserved() {
        return reserved;
    }
}

package org.mastercoin.rpc;

import com.google.bitcoin.core.Address;

import java.math.BigDecimal;

/**
 * Balance data for a specific Mastercoin CurrencyID in a single Bitcoin address
 *
 * A Java representation of the JSON entry returned by getallbalancesforid_MP
 */
public class MPBalanceEntry {
    private Address address;
    private BigDecimal balance;
    private BigDecimal reserved;

    public MPBalanceEntry(Address address, BigDecimal balance, BigDecimal reserved) {
        this.address = address;
        this.balance = balance;
        this.reserved = reserved;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MPBalanceEntry that = (MPBalanceEntry) o;

        if (!address.equals(that.address)) return false;
        if (!balance.equals(that.balance)) return false;
        if (!reserved.equals(that.reserved)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = address.hashCode();
        result = 31 * result + balance.hashCode();
        result = 31 * result + reserved.hashCode();
        return result;
    }

    public Address getAddress() {
        return address;
    }

    public BigDecimal getBalance() {
        return balance;
    }

    public BigDecimal getReserved() {
        return reserved;
    }
}

Correct equals() implementation, add hashCode()

(Use IntelliJ to Generate)


package hudson.plugins.cobertura.targets;

import junit.framework.TestCase;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * Created by IntelliJ IDEA.
 * User: stephen
 * Date: 21-Oct-2007
 * Time: 18:01:31
 * To change this template use File | Settings | File Templates.
 */
public class CoveragePaintTest extends TestCase {

    public CoveragePaintTest(String string) {
        super(string);
    }

    public void testSerializable() throws Exception {
        CoveragePaint instance = new CoveragePaint(CoverageElement.JAVA_FILE);
        instance.paint(5, 7, 4, 5);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(instance);
        oos.flush();
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bis);
        CoveragePaint copy = (CoveragePaint) ois.readObject();
        assertEquals(instance.getLineCoverage(), copy.getLineCoverage());
        assertEquals(instance.getConditionalCoverage(), copy.getConditionalCoverage());
    }
}

package hudson.plugins.cobertura.targets;

import junit.framework.TestCase;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * Created by IntelliJ IDEA.
 * User: stephen
 * Date: 21-Oct-2007
 * Time: 18:01:31
 * To change this template use File | Settings | File Templates.
 */
public class CoveragePaintTest extends TestCase {

    public CoveragePaintTest(String string) {
        super(string);
    }

    public void testTotalLines() {
        CoveragePaint instance = new CoveragePaint(CoverageElement.JAVA_FILE);
        assertEquals(0, instance.getTotalLines());
        instance.setTotalLines(451);
        assertEquals(451, instance.getTotalLines());
        instance.setTotalLines(179);
        assertEquals(179, instance.getTotalLines());
    }

    public void testSerializable() throws Exception {
        CoveragePaint instance = new CoveragePaint(CoverageElement.JAVA_FILE);
        instance.paint(5, 7, 4, 5);
        instance.setTotalLines(314);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(instance);
        oos.flush();
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bis);
        CoveragePaint copy = (CoveragePaint) ois.readObject();
        assertEquals(instance.getLineCoverage(), copy.getLineCoverage());
        assertEquals(instance.getConditionalCoverage(), copy.getConditionalCoverage());
        assertEquals(314, copy.getTotalLines());
    }
}

Add a test and some asserts to coverage paint total lines


package alien4cloud.it;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = {
"classpath:alien/rest/cloud/cloud_avz.feature"
}, format = { "pretty", "html:target/cucumber/cloud", "json:target/cucumber/cucumber-cloud.json" })
public class RunCloudIT {
}

package alien4cloud.it;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = {
"classpath:alien/rest/cloud"
}, format = { "pretty", "html:target/cucumber/cloud", "json:target/cucumber/cucumber-cloud.json" })
public class RunCloudIT {
}

Validate HA groups on a topology REST It tests


package com.elmakers.mine.bukkit.wand;

import org.bukkit.configuration.ConfigurationSection;

import com.elmakers.mine.bukkit.api.magic.Mage;

public class WandUpgradeSlot {
    private final String slotType;
    private boolean hidden = false;
    private boolean swappable = false;
    private Wand slotted;

    public WandUpgradeSlot(String slotType) {
        this.slotType = slotType;
    }

    public WandUpgradeSlot(String configKey, ConfigurationSection config) {
        slotType = config.getString("type", configKey);
        hidden = config.getBoolean("hidden", false);
        swappable = config.getBoolean("swappable", false);
    }

    public Wand getSlotted() {
        return slotted;
    }

    public boolean addSlotted(Wand upgrade, Mage mage) {
        String slotType = upgrade.getSlot();
        if (slotType == null || slotType.isEmpty()) {
            return false;
        }
        if (!slotType.equals(slotType)) {
            return false;
        }
        if (slotted == null) {
            slotted = upgrade;
            return true;
        }
        if (!swappable || mage == null) {
            return false;
        }
        mage.giveItem(slotted.getItem());
        slotted = upgrade;
        return true;
    }

    public boolean isHidden() {
        return hidden;
    }

    public String getType() {
        return slotType;
    }
}

package com.elmakers.mine.bukkit.wand;

import org.bukkit.configuration.ConfigurationSection;

import com.elmakers.mine.bukkit.api.magic.Mage;

public class WandUpgradeSlot {
    private final String slotType;
    private boolean hidden = false;
    private boolean swappable = false;
    private boolean replaceable = false;
    private Wand slotted;

    public WandUpgradeSlot(String slotType) {
        this.slotType = slotType;
    }

    public WandUpgradeSlot(String configKey, ConfigurationSection config) {
        slotType = config.getString("type", configKey);
        hidden = config.getBoolean("hidden", false);
        swappable = config.getBoolean("swappable", false);
        replaceable = config.getBoolean("replaceable", false);
    }

    public Wand getSlotted() {
        return slotted;
    }

    public boolean addSlotted(Wand upgrade, Mage mage) {
        String slotType = upgrade.getSlot();
        if (slotType == null || slotType.isEmpty()) {
            return false;
        }
        if (!slotType.equals(slotType)) {
            return false;
        }
        if (slotted == null || replaceable) {
            slotted = upgrade;
            return true;
        }
        if (!swappable || mage == null) {
            return false;
        }
        mage.giveItem(slotted.getItem());
        slotted = upgrade;
        return true;
    }

    public boolean isHidden() {
        return hidden;
    }

    public String getType() {
        return slotType;
    }
}

Add replaceable slot tag, for upgrades that can be replaced without returning the existing upgrade


package edu.pdx.cs410J.chances;

import edu.pdx.cs410J.AbstractAppointmentBook;
import edu.pdx.cs410J.AppointmentBookParser;
import edu.pdx.cs410J.ParserException;

/**
 * @author chancesnow
 */
public class TextParser implements AppointmentBookParser
{
    @Override
    public AbstractAppointmentBook parse() throws ParserException
    {
        return null;
    }
}

package edu.pdx.cs410J.chances;

import edu.pdx.cs410J.AbstractAppointmentBook;
import edu.pdx.cs410J.AppointmentBookParser;
import edu.pdx.cs410J.ParserException;

import java.io.File;

/**
 * @author chancesnow
 */
public class TextParser implements AppointmentBookParser
{
    private File file;

    public TextParser(String filePath)
    {
        file = new File(filePath);

        if (!file.exists() || !file.isDirectory()) {
            file = null;
        }
    }

    @Override
    public AbstractAppointmentBook parse() throws ParserException
    {
        return null;
    }
}

Add constructor accepting file path

Add constructor accepting file path


package org.cryptonit.cloud.interfaces;

import java.security.PrivateKey;
import java.security.PublicKey;

public interface KeyStore {
    public enum KeyParameters {
        RSA_2048("RSA", null, 2048),
        RSA_4096("RSA", null, 4096),
        EC_P256("EC", "P-256", 256),
        EC_P384("EC", "P-384", 384),
        EC_P521("EC", "P-521", 521);

        final private String algorithm;
        final private String parameter;
        final private int size;

        KeyParameters(String algorithm, String parameter, int size) {
            this.algorithm = algorithm;
            this.parameter = parameter;
            this.size = size;
        }

        public String getAlgorithm() {
            return algorithm;
        }

        public String getParameter() {
            return parameter;
        }

        public int getSize() {
            return size;
        }
    };

    PrivateKey getPrivateKey(String domain, String keyIdentifier);

    PublicKey getPublicKey(String domain, String keyIdentifier);
}

package org.cryptonit.cloud.interfaces;

import java.security.PrivateKey;
import java.security.PublicKey;

public interface KeyStore {
    public enum KeyParameters {
        RSA_2048("RSA", null, 2048),
        RSA_4096("RSA", null, 4096),
        EC_P256("EC", "P-256", 256),
        EC_P384("EC", "P-384", 384),
        EC_P521("EC", "P-521", 521);

        final private String algorithm;
        final private String parameter;
        final private int size;

        KeyParameters(String algorithm, String parameter, int size) {
            this.algorithm = algorithm;
            this.parameter = parameter;
            this.size = size;
        }

        public String getAlgorithm() {
            return algorithm;
        }

        public String getParameter() {
            return parameter;
        }

        public int getSize() {
            return size;
        }
    };

    String generateKey(String domain, KeyParameters params);

    PrivateKey getPrivateKey(String domain, String keyIdentifier);

    PublicKey getPublicKey(String domain, String keyIdentifier);
}

Add key generation function to interface


package org.radargun.config;

import java.util.List;

import static org.radargun.config.VmArgUtils.ensureArg;
import static org.radargun.config.VmArgUtils.replace;

public class FlightRecorder implements VmArg {
   @Property(doc = "Start flight recording for the benchmark.", optional = false)
   private boolean enabled = false;

   @Property(doc = "File for the recording.")
   private String filename;

   @Property(doc = "Settings file with recording configuration.")
   private String settings;

   @Override
   public void setArgs(List<String> args) {
      if (!enabled)
         return;
      StringBuilder recordingParams = new StringBuilder("=compress=false,delay=10s,duration=24h");
      if (filename != null)
         recordingParams.append(",filename=").append(filename);
      if (settings != null)
         recordingParams.append(",settings=").append(settings);
      ensureArg(args, "-XX:+UnlockCommercialFeatures");
      ensureArg(args, "-XX:+FlightRecorder");
      replace(args, "-XX:StartFlightRecording", recordingParams.toString());
   }

   public boolean isEnabled() {
      return enabled;
   }

   public String getFilename() {
      return filename;
   }

   public String getSettings() {
      return settings;
   }
}

package org.radargun.config;

import java.util.List;

import static org.radargun.config.VmArgUtils.ensureArg;
import static org.radargun.config.VmArgUtils.replace;

public class FlightRecorder implements VmArg {
   @Property(doc = "Start flight recording for the benchmark.", optional = false)
   private boolean enabled = false;

   @Property(doc = "File for the recording.")
   private String filename;

   @Property(doc = "Settings file with recording configuration.")
   private String settings;

   @Override
   public void setArgs(List<String> args) {
      if (!enabled)
         return;
      StringBuilder recordingParams = new StringBuilder("=delay=10s,duration=24h");
      if (filename != null)
         recordingParams.append(",filename=").append(filename);
      if (settings != null)
         recordingParams.append(",settings=").append(settings);
      ensureArg(args, "-XX:+UnlockCommercialFeatures");
      ensureArg(args, "-XX:+FlightRecorder");
      replace(args, "-XX:StartFlightRecording", recordingParams.toString());
   }

   public boolean isEnabled() {
      return enabled;
   }

   public String getFilename() {
      return filename;
   }

   public String getSettings() {
      return settings;
   }

}

Fix Unknown argument 'compress' in diagnostic for JDK11


package com.voxelwind.nbt.util;

import com.voxelwind.nbt.tags.CompoundTag;
import com.voxelwind.nbt.tags.Tag;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CompoundTagBuilder {
    private final Map<String, Tag<?>> tagMap = new HashMap<>();

    public static CompoundTagBuilder builder() {
        return new CompoundTagBuilder();
    }

    public static CompoundTagBuilder from(CompoundTag tag) {
        CompoundTagBuilder builder = new CompoundTagBuilder();
        builder.tagMap.putAll(tag.getValue());
        return builder;
    }

    public CompoundTagBuilder tag(Tag<?> tag) {
        tagMap.put(tag.getName(), tag);
        return this;
    }

    public CompoundTag buildRootTag() {
        return new CompoundTag("", tagMap);
    }

    public CompoundTag build(String tagName) {
        return new CompoundTag(tagName, tagMap);
    }
}

package com.voxelwind.nbt.util;

import com.voxelwind.nbt.tags.*;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CompoundTagBuilder {
    private final Map<String, Tag<?>> tagMap = new HashMap<>();

    public static CompoundTagBuilder builder() {
        return new CompoundTagBuilder();
    }

    public static CompoundTagBuilder from(CompoundTag tag) {
        CompoundTagBuilder builder = new CompoundTagBuilder();
        builder.tagMap.putAll(tag.getValue());
        return builder;
    }

    public CompoundTagBuilder tag(Tag<?> tag) {
        tagMap.put(tag.getName(), tag);
        return this;
    }

    public CompoundTagBuilder tag(String name, byte value) {
        return tag(new ByteTag(name, value));
    }

    public CompoundTagBuilder tag(String name, byte [] value) {
        return tag(new ByteArrayTag(name, value));
    }

    public CompoundTagBuilder tag(String name, double value) {
        return tag(new DoubleTag(name, value));
    }

    public CompoundTagBuilder tag(String name, float value) {
        return tag(new FloatTag(name, value));
    }

    public CompoundTagBuilder tag(String name, int[] value) {
        return tag(new IntArrayTag(name, value));
    }

    public CompoundTagBuilder tag(String name, int value) {
        return tag(new IntTag(name, value));
    }

    public CompoundTagBuilder tag(String name, long value) {
        return tag(new LongTag(name, value));
    }

    public CompoundTagBuilder tag(String name, short value) {
        return tag(new ShortTag(name, value));
    }

    public CompoundTagBuilder tag(String name, String value) {
        return tag(new StringTag(name, value));
    }

    public CompoundTag buildRootTag() {
        return new CompoundTag("", tagMap);
    }

    public CompoundTag build(String tagName) {
        return new CompoundTag(tagName, tagMap);
    }
}

Add type-related tag methods to nbt-builder