Skip to content

Commit be7ff72

Browse files
committed
Merge remote-tracking branch 'origin/master' into AustinShalit-CheckStyle
2 parents 5a611d1 + f858102 commit be7ff72

File tree

70 files changed

+1554
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1554
-328
lines changed

.travis-scripts/push-javadoc-to-gh-pages.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Source of file: http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/
44
if [ "$TRAVIS_REPO_SLUG" == "WPIRoboticsProjects/GRIP" ] && [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
55

6+
echo -e "Generating javadoc...\n"
7+
./gradlew aggregateJavadocs
8+
69
echo -e "Publishing javadoc...\n"
710

811
cp -R build/docs/javadoc $HOME/javadoc-latest

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ before_install:
2121
- sh -e /etc/init.d/xvfb start
2222
- pip install --user codecov
2323

24-
install: ./gradlew :ui:assemble --stacktrace
24+
# Only do an assemble when we aren't building a pull request
25+
install:
26+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && ./gradlew :ui:assemble --stacktrace || ./gradlew --stacktrace '
2527

26-
after_failure: #Run again with debug info enabled
27-
- ./gradlew check --stacktrace -PprintTestResults
28+
script:
29+
- ./gradlew check --stacktrace -PprintTestResults
2830

2931
after_success:
3032
- codecov
31-
- ./gradlew aggregateJavadocs
3233
- .travis-scripts/push-javadoc-to-gh-pages.sh
3334
- .travis-scripts/before-deploy.sh
3435

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Join the chat at https://gitter.im/WPIRoboticsProjects/GRIP](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/WPIRoboticsProjects/GRIP?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44
[![Build Status](https://travis-ci.org/WPIRoboticsProjects/GRIP.svg?branch=master)](https://travis-ci.org/WPIRoboticsProjects/GRIP)
5-
[![Build status](https://ci.appveyor.com/api/projects/status/9xl8pggec4l75pqb/branch/master?svg=true)](https://ci.appveyor.com/project/ThomasJClark/grip/branch/master)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/sbrd2nhpiktlhf58/branch/master?svg=true)](https://ci.appveyor.com/project/JLLeitschuh/grip/branch/master)
66
[![codecov.io](http://codecov.io/github/WPIRoboticsProjects/GRIP/coverage.svg?branch=master)](http://codecov.io/github/WPIRoboticsProjects/GRIP?branch=master)
77
[![Github Releases](https://img.shields.io/github/downloads/WPIRoboticsProjects/GRIP/total.svg)](https://github.com/WPIRoboticsProjects/GRIP/releases/latest)
88

appveyor.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ install:
22
- choco install -y InnoSetup
33

44
build_script:
5-
- gradlew.bat :ui:assemble --stacktrace
5+
- gradlew.bat :ui:assemble --stacktrace -PprintTestResults
66

77
# to run your custom scripts instead of automatic tests
88
test_script:
@@ -11,12 +11,10 @@ test_script:
1111
platform:
1212
- x64
1313

14-
after_build:
15-
- dir build /s
16-
1714
artifacts:
1815
- path: ui\build\distributions\*.exe
1916

17+
2018
deploy:
2119
provider: GitHub
2220
description: ''

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ allprojects {
4141
testCompile group: 'junit', name: 'junit', version: '4.12'
4242
}
4343

44-
version = '0.3.0'
44+
version = '1.0.0-rc4'
4545

4646
compileJava {
4747
options.compilerArgs << "-g"
@@ -96,6 +96,9 @@ project(":core") {
9696
repositories {
9797
flatDir {
9898
dirs 'libs'
99+
maven {
100+
url = "http://first.wpi.edu/FRC/roborio/maven/development"
101+
}
99102
}
100103
}
101104

@@ -114,6 +117,8 @@ project(":core") {
114117
// https://github.com/google/guice/wiki/OptionalAOP
115118
compile group: 'com.google.inject', name: 'guice', version: '4.0', classifier: 'no_aop'
116119
compile group: 'com.google.inject.extensions', name: 'guice-assistedinject', version: '4.0'
120+
compile group: 'edu.wpi.first.wpilib.networktables.java', name: 'NetworkTables', version: '3.0.0-SNAPSHOT', classifier: 'desktop'
121+
compile group: 'edu.wpi.first.wpilib.networktables.java', name: 'NetworkTables', version: '3.0.0-SNAPSHOT', classifier: 'arm'
117122
}
118123

119124
mainClassName = 'edu.wpi.grip.core.Main'

buildSrc/src/main/java/edu/wpi/gripgenerator/defaults/PrimitiveDefaultValue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ public PrimitiveDefaultValue(PrimitiveType type) {
4545
);
4646
break;
4747
case Int:
48-
this.viewValue = "SPINNER";
48+
this.viewValue = "TEXT";
4949
this.domainValue = createDomainValueExpression(
5050
new IntegerLiteralExpr("Integer.MIN_VALUE"),
5151
new IntegerLiteralExpr("Integer.MAX_VALUE")
5252
);
5353
break;
5454
case Float:
55-
this.viewValue = "SPINNER";
55+
this.viewValue = "TEXT";
5656
this.domainValue = createDomainValueExpression(
5757
new DoubleLiteralExpr("-Float.MAX_VALUE"),
5858
new DoubleLiteralExpr("Float.MAX_VALUE")
5959
);
6060
break;
6161
case Double:
62-
this.viewValue = "SPINNER";
62+
this.viewValue = "TEXT";
6363
this.domainValue = createDomainValueExpression(
6464
new DoubleLiteralExpr("-Double.MAX_VALUE"),
6565
new DoubleLiteralExpr("Double.MAX_VALUE")
6666
);
6767
break;
6868
case Char:
69-
this.viewValue = "SPINNER";
69+
this.viewValue = "TEXT";
7070
this.domainValue = createDomainValueExpression(
7171
new CharLiteralExpr(Character.toString(Character.MIN_VALUE)),
7272
new CharLiteralExpr(Character.toString(Character.MAX_VALUE))

core/src/main/java/edu/wpi/grip/core/Connection.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public InputSocket<T> getInputSocket() {
4848
@Subscribe
4949
public void onConnectionAdded(ConnectionAddedEvent event) {
5050
if (event.getConnection().equals(this)) {
51+
inputSocket.addConnection(this);
52+
outputSocket.addConnection(this);
5153
inputSocket.setValueOptional(outputSocket.getValue());
5254
}
5355
}
@@ -59,6 +61,14 @@ public void onOutputChanged(SocketChangedEvent e) {
5961
}
6062
}
6163

64+
@Subscribe
65+
public void onConnectionRemoved(ConnectionRemovedEvent e) {
66+
if (e.getConnection() == this) {
67+
inputSocket.removeConnection(this);
68+
outputSocket.removeConnection(this);
69+
}
70+
}
71+
6272
@Subscribe
6373
public void removeConnection(StepRemovedEvent e) {
6474
// Remove this connection if one of the steps it was connected to was removed

core/src/main/java/edu/wpi/grip/core/GRIPCoreModule.java

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public GRIPCoreModule() {
3434

3535
try {
3636
// Remove the default handlers that stream to System.err
37-
for(Handler handler : globalLogger.getHandlers()) {
37+
for (Handler handler : globalLogger.getHandlers()) {
3838
globalLogger.removeHandler(handler);
3939
}
4040

@@ -45,7 +45,7 @@ public GRIPCoreModule() {
4545
globalLogger.setLevel(Level.FINE);
4646

4747
// We need to stream to System.out instead of System.err
48-
final StreamHandler sh = new StreamHandler(System.out, new SimpleFormatter()) {
48+
final StreamHandler sh = new StreamHandler(System.out, new SimpleFormatter()) {
4949

5050
@Override
5151
public synchronized void publish(final LogRecord record) {
@@ -114,14 +114,36 @@ private void onSubscriberException(Throwable exception, SubscriberExceptionConte
114114
}
115115
}
116116

117+
/*
118+
* We intentionally catch the throwable because we can't be sure what will happen.
119+
* We drop the last throwable because we clearly have a problem beyond our control.
120+
*/
121+
@SuppressWarnings({"PMD.AvoidCatchingThrowable", "PMD.EmptyCatchBlock"})
117122
private void onThreadException(Thread thread, Throwable exception) {
118-
if (exception instanceof InterruptedException) {
119-
logger.log(Level.FINE, "InterruptedException from thread " + thread, exception);
120-
Thread.currentThread().interrupt();
121-
} else {
122-
// This can potentially happen before the main class has even been loaded to handle these exceptions
123-
logger.log(Level.SEVERE, "Uncaught Exception on thread " + thread, exception);
124-
eventBus.post(new UnexpectedThrowableEvent(exception, thread + " threw an exception"));
123+
// Don't do anything outside of a try catch block when dealing with thread death
124+
try {
125+
if (exception instanceof Error && !(exception instanceof AssertionError)) {
126+
// Try, this may not work. but its worth a shot.
127+
logger.log(Level.SEVERE, "Error from " + thread, exception);
128+
} else if (exception instanceof InterruptedException) {
129+
logger.log(Level.FINE, "InterruptedException from thread " + thread, exception);
130+
Thread.currentThread().interrupt();
131+
} else {
132+
// This can potentially happen before the main class has even been loaded to handle these exceptions
133+
logger.log(Level.SEVERE, "Uncaught Exception on thread " + thread, exception);
134+
final UnexpectedThrowableEvent event = new UnexpectedThrowableEvent(exception, thread + " threw an exception");
135+
eventBus.post(event);
136+
// It is possible that the event was never handled.
137+
// If it wasn't we want to perform the shutdown hook here.
138+
event.shutdownIfFatal();
139+
}
140+
} catch (Throwable throwable) {
141+
try {
142+
logger.log(Level.SEVERE, "Failed to handle thread exception", throwable);
143+
} catch (Throwable throwable1) {
144+
// Seriously, just give up at this point.
145+
}
125146
}
147+
// Don't do anything outside of a try catch block when dealing with thread death
126148
}
127149
}

core/src/main/java/edu/wpi/grip/core/InputSocket.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ public InputSocket(EventBus eventBus, SocketHint<T> socketHint) {
2323
}
2424

2525
/**
26-
* Reset the socket to its default value when it's no longer connected to anything. This prevents removed
27-
* connections from continuing to have an effect on steps because they still hold references to the values they
28-
* were connected to.
26+
* {@inheritDoc}
2927
*/
30-
@Subscribe
31-
public void onDisconnected(SocketConnectedChangedEvent event) {
32-
if (event.getSocket() == this && this.getConnections().isEmpty()) {
28+
@Override
29+
protected void onDisconnected() {
30+
super.onDisconnected();
31+
if (this.getConnections().isEmpty()) {
3332
this.setValue(this.getSocketHint().createInitialValue().orElse(null));
3433
}
3534
}

core/src/main/java/edu/wpi/grip/core/Main.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
import com.google.inject.Injector;
77
import edu.wpi.grip.core.events.ExceptionClearedEvent;
88
import edu.wpi.grip.core.events.ExceptionEvent;
9-
import edu.wpi.grip.core.events.UnexpectedThrowableEvent;
109
import edu.wpi.grip.core.operations.Operations;
1110
import edu.wpi.grip.core.serialization.Project;
1211
import edu.wpi.grip.generated.CVOperations;
1312

1413
import javax.inject.Inject;
1514
import java.io.File;
1615
import java.io.IOException;
17-
import java.util.logging.*;
16+
import java.util.logging.Level;
17+
import java.util.logging.Logger;
1818

1919
/**
2020
* Main driver class for headless mode
@@ -76,14 +76,4 @@ public final void onExceptionClearedEvent(ExceptionClearedEvent event) {
7676
Logger.getLogger(event.getOrigin().getClass().getName()).log(Level.INFO, "Exception Cleared Event");
7777
}
7878

79-
/**
80-
* When an unexpected error happens in headless mode, print a stack trace and exit.
81-
*/
82-
@Subscribe
83-
public final void onUnexpectedThrowableEvent(UnexpectedThrowableEvent event) {
84-
logger.log(Level.SEVERE, "UnexpectedThrowableEvent", event.getThrowable());
85-
if (event.isFatal()) {
86-
System.exit(1);
87-
}
88-
}
8979
}

0 commit comments

Comments
 (0)