Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 10b93c8e38e9ca8a13c1e21caa4669b94c3ace2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*******************************************************************************
 * Copyright (c) 2010, 2013 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.coordinator;

import java.util.TimerTask;

import org.eclipse.osgi.util.NLS;
import org.osgi.service.coordinator.Coordination;
import org.osgi.service.log.LogService;

public class CoordinationTimerTask extends TimerTask {
	private final CoordinationImpl coordination;

	public CoordinationTimerTask(CoordinationImpl coordination) {
		if (coordination == null)
			throw new NullPointerException(NLS.bind(Messages.NullParameter, "coordination")); //$NON-NLS-1$
		this.coordination = coordination;
	}

	@Override
	public void run() {
		// Catch all exceptions and errors in order to prevent the timer 
		// thread from stopping.
		try {
			coordination.fail(Coordination.TIMEOUT);
		} catch (Throwable t) {
			coordination.getLogService().log(LogService.LOG_ERROR, NLS.bind(Messages.CoordinationTimedOutError, new Object[]{coordination.getName(), coordination.getId(), Thread.currentThread()}), t);
		}
	}
}

Back to the top